Skip to content

Instantly share code, notes, and snippets.

@nthx
Created September 3, 2012 01:36
Show Gist options
  • Save nthx/3606120 to your computer and use it in GitHub Desktop.
Save nthx/3606120 to your computer and use it in GitHub Desktop.
Hello World TamperMonkey script with jquery/sugarjs
// ==UserScript==
// @match https://yourwebsite.com/xyz
// @require http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js
// @require http://cdnjs.cloudflare.com/ajax/libs/sugar/1.3/sugar.min.js
// ==/UserScript==
alert('Hello, I got jQuery included and sugarJs too');
var runEverySecond = function(){
$('p').find('img').attr('width', '0px');
$('a').css('padding', '0px');
console.debug('Hello Word has ' + $('p').length + ' paragraphs');
};
$(document).ready(function() {
setInterval(runEverySecond,1000);
});
@fvandillen
Copy link

This doesn't work for me. I'm getting the following error on Chrome with Tampermonkey:
ERROR: Execution of script 'XX' failed! undefined is not a function

// ==UserScript==
// Other userscript stuff here
// @require https://code.jquery.com/jquery-latest.js
// ==/UserScript==

$(document).ready(function() {
    console.log("I'm running with jQuery!");
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment