Skip to content

Instantly share code, notes, and snippets.

@slyphon
Created September 7, 2011 17:22
Show Gist options
  • Save slyphon/1201172 to your computer and use it in GitHub Desktop.
Save slyphon/1201172 to your computer and use it in GitHub Desktop.
strips out the annoying utm_* cruft from google reader urls
// ==UserScript==
// @name FeedBurnerTrackingQueryStripper
// @namespace http://creazy.net/
// @match http://*/*
// @match https://*/*
// ==/UserScript==
(function () {
if ( location.search.match(/utm_source=feedburner/) ) {
var new_url = '';
// check canonical
var links = document.getElementsByTagName('link');
for ( var i=0; i<links.length; i++ ) {
if ( links[i].getAttribute('rel') == 'canonical' ) {
new_url = links[i].getAttribute('href');
//alert('use canonical : '+new_url);
break;
}
}
// sprit params
if ( !new_url ) {
new_url = location.href.replace(
/([\?\&]utm_(source|medium|campaign|content)=.+)/ig
,''
);
//alert('sprit url : '+new_url);
}
if ( new_url ) location.replace(new_url);
}
})();
@Korb
Copy link

Korb commented Apr 25, 2022

strips out the annoying utm_* cruft from google reader urls

Only Google Reader (RIP)? But

// @match          http://*/*
// @match          https://*/*

This is the modification of links for tracking using Google Analytics, am I right? Perhaps the description of the script could be formulated more successfully.

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