Last active
April 1, 2016 08:26
-
-
Save v2keener/9665787 to your computer and use it in GitHub Desktop.
Snippet: Base TamperMonkey injection script with jQuery via Google APIs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name ${1:Some fancy name} | |
// @namespace ${2:https://gist.github.com/9665787} | |
// @version 0.1 | |
// @description ${3:Some description} | |
// @match /* ALLOW TAMPERMONKEY TO FILL THIS IN *OR* COPY FROM TAMPERMONKEY */ | |
// @copyright 2014+, ${4:Gustavo Keener} | |
// ==/UserScript== | |
// Add jQuery, unless it already exists | |
if(typeof jQuery === 'undefined'|| !jQuery){ | |
(function(){ | |
var s=document.createElement('script'); | |
s.setAttribute('src','http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.js'); | |
if(typeof jQuery=='undefined'){ | |
document.getElementsByTagName('head')[0].appendChild(s); | |
} | |
})(); | |
} | |
(function(){ | |
var codeToExecute = function(){ | |
/***********************/ | |
// YOUR CODE HERE | |
/***********************/ | |
${5:alert('This is a message from a TamperMonkey script!');} | |
}; | |
var intervalInt = window.setInterval(function(){ | |
if(typeof jQuery !== 'undefined' && jQuery){ | |
// Clear this interval | |
window.clearInterval(intervalInt); | |
codeToExecute(); | |
} | |
}, 100); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment