Skip to content

Instantly share code, notes, and snippets.

@vjk2005
Created March 2, 2017 06:23
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vjk2005/39ad785203c30da114a08f57157210ad to your computer and use it in GitHub Desktop.
Save vjk2005/39ad785203c30da114a08f57157210ad to your computer and use it in GitHub Desktop.
Inject jquery into the most active tab using JXA (Javascript for Automation, OSX)
// put this inside a Run Javascript block in Automator
app.doJavaScript("var script = document.createElement('script'); script.src = 'https://ajax.googleapis.com/ajax/libs/jquery/1.6.3/jquery.min.js'; document.getElementsByTagName('head')[0].appendChild(script);", {
in: app.windows[0].currentTab
})
delay(1); // wait for jQuery to load
//... jQuery is now loaded, now add the rest of the script
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment