Created
September 7, 2011 17:22
-
-
Save slyphon/1201172 to your computer and use it in GitHub Desktop.
strips out the annoying utm_* cruft from google reader urls
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 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); | |
} | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Only Google Reader (RIP)? But
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.