michaelfox + userscripts   67

User Scripts - The Chromium Projects
Chromium and Google Chrome (version 4 and higher) have built-in support for Greasemonkey-style user scripts.

To use, click on any .user.js file. You should see an install dialog. Press OK to install.

Known issues:
Chromium does not support @require, @resource, unsafeWindow, GM_registerMenuCommand, GM_setValue, or GM_getValue.
GM_xmlhttpRequest is same-origin only.

Match Patterns

The preferred way to specify the pages that a user script should run against in Chromium is the @match attribute. Here are some examples of its use:

// ==UserScript==
// @match http://*
// @match http://*.google.com/*
// @match http://www.google.com/*
// ==/UserScript==

See these comments for details on the @match syntax. 

Support for Greasemonkey-style @include patterns is also implemented for compatibility, but @match is preferred.

With Greasemonkey-style @include rules, it is not possible for Chrome to know for certain the domains a script will run on (because google.* can also run on google.evil.com). Because of this, Chrome just tells users that these scripts will run on all domains, which is sometimes scarier than necessary. With @match, Chrome will tell users the correct set of domains a user script will run on.
chrome  javascript  userscripts  greasemonkey  wiki  reference 
december 2010 by michaelfox
gist: 626834 - userscript: Drop the UTM params from a URL when the page loads- GitHub
// ==UserScript==
// @name UTM param stripper
// @author Paul Irish
// @namespace http://github.com/paulirish
// @description Drop the UTM params from a URL when the page loads.
// @extra Cuz you know they're all ugly n shit.
// @include http://*
// ==/UserScript==


// save this as utmstrip.user.js and drag it into Chrome or Firebug (with greasemonkey)


if (/^\?utm_/.test(location.search) && window.history.replaceState){
window.history.replaceState({},'', location.href.replace(/\?utm_.*/,''));
}



// also..
// this is just as useful on your own site.. in case you have feedburner tracking or whatever.
gist-626834  gist  userscripts  javascript 
october 2010 by michaelfox
Conditional Logging - GreaseSpot
An even simpler option, retaining all of Firebug's console routines, and not interfering with additional parameters.

const DEBUG = 1;
if (!DEBUG) {
var console = {
log: function() {},
info: function() {},
warn: function() {},
error: function() {},
};
}
greasemonkey  userscripts  javascript  debug  console  firebug  firefox  logging  webdev  tools  snippets  code  browser 
april 2010 by michaelfox
Location hack - GreaseSpot
The location hack is an ugly but useful way to interact with the content scope of the page being user scripted. It does this by indirectly evaling strings within that scope.
greasemonkey  userscripts  javascript  bookmarklets 
april 2010 by michaelfox

Copy this bookmark:



description:


tags: