CocoaPods trunk is moving to be read-only. Read more on the blog, there are 19 months to go.
TestsTested | ✗ |
LangLanguage | Obj-CObjective C |
License | BSD |
ReleasedLast Release | Dec 2014 |
Maintained by Boy van Amstel.
DCOURLGrabber uses AppleScript to get the URL from most popular browsers.
It monitors when the user switches apps and takes note of which browser was last active. When asked, it then returns the URL from the active tab of that browser.
DCOURLGrabber is used in Tapetrap.
Clone this repo and add both the source files and AppleScripts to your project.
To simply retrieve the URL from a browser (Chrome) you have running, use the following:
DCOURLGrabber *grabber = [[DCOURLGrabber alloc] init];
NSURL *url = [grabber grabURLFromBundleID:@"com.google.Chrome" withError:&grabError];
if(grabError) {
NSLog(@"Failed to retrieve URL: %@", grabError);
} else {
NSLog(@"Got URL: %@", url.absoluteString);
}
First setup monitoring like this:
DCOURLGrabber *grabber = [[DCOURLGrabber alloc] init];
[grabber startMonitoring];
Then simply grab the URL when you want, like so:
NSURL *url = [grabber grabURLWithError:&grabError];
if(grabError) {
NSLog(@"Failed to retrieve URL: %@", grabError);
} else {
NSLog(@"Got URL: %@", url.absoluteString);
}
AppleScripts are loaded by checking the app bundle for some.bundle.id.scpt. Simply adding a new file to your app bundle should add it to DCOURLGrabber as well.
Adding a method to expand the list of supported bundle IDs should take care of the rest.
New BSD License, see LICENSE
for details.