Skip to content

Commit

Permalink
match whole url parameters (so that ref= doesn't match href=, fixes F…
Browse files Browse the repository at this point in the history
…acebook Like button)
  • Loading branch information
akirk committed Jun 26, 2010
1 parent 706fdff commit 3eaeb98
Showing 1 changed file with 14 additions and 13 deletions.
27 changes: 14 additions & 13 deletions injected_script.js
Expand Up @@ -2,21 +2,22 @@ if (window.location.search != "") {
window_href = window.location.href;

// Remove tracking crap
window_href = window_href.replace(/utm_source=[^&]*(&|$)/, ''); // Google analytics tracking variable
window_href = window_href.replace(/utm_medium=[^&]*(&|$)/, ''); // Google analytics tracking variable
window_href = window_href.replace(/utm_campaign=[^&]*(&|$)/, ''); // Google analytics tracking variable
window_href = window_href.replace(/utm_content=[^&]*(&|$)/, ''); // Google analytics tracking variable
window_href = window_href.replace(/utm_term=[^&]*(&|$)/, ''); // Google analytics tracking variable
window_href = window_href.replace(/partner=[^&]*(&|$)/, ''); // From nytimes.com feeds
window_href = window_href.replace(/emc=[^&]*(&|$)/, ''); // From nytimes.com feeds
window_href = window_href.replace(/lsrc=[^&]*(&|$)/, ''); // From macworld.com feeds
window_href = window_href.replace(/eref=[^&]*(&|$)/, ''); // From cnn.com feeds
window_href = window_href.replace(/ref=[^&]*(&|$)/, ''); // From cbc.ca/news feeds
window_href = window_href.replace(/bn=[^&]*(&|$)/, ''); // From thestar.com links
window_href = window_href.replace(/cmpid=[^&]*(&|$)/, ''); // From theglobeandmail.com links
window_href = window_href.replace(/([&?])utm_source=[^&]*(?:&|$)/, '$1'); // Google analytics tracking variable
window_href = window_href.replace(/([&?])utm_medium=[^&]*(?:&|$)/, '$1'); // Google analytics tracking variable
window_href = window_href.replace(/([&?])utm_campaign=[^&]*(?:&|$)/, '$1'); // Google analytics tracking variable
window_href = window_href.replace(/([&?])utm_content=[^&]*(?:&|$)/, '$1'); // Google analytics tracking variable
window_href = window_href.replace(/([&?])utm_term=[^&]*(?:&|$)/, '$1'); // Google analytics tracking variable
window_href = window_href.replace(/([&?])partner=[^&]*(?:&|$)/, '$1'); // From nytimes.com feeds
window_href = window_href.replace(/([&?])emc=[^&]*(?:&|$)/, '$1'); // From nytimes.com feeds
window_href = window_href.replace(/([&?])lsrc=[^&]*(?:&|$)/, '$1'); // From macworld.com feeds
window_href = window_href.replace(/([&?])eref=[^&]*(?:&|$)/, '$1'); // From cnn.com feeds
window_href = window_href.replace(/([&?])ref=[^&]*(?:&|$)/, '$1'); // From cbc.ca/news feeds
window_href = window_href.replace(/([&?])bn=[^&]*(?:&|$)/, '$1'); // From thestar.com links
window_href = window_href.replace(/([&?])cmpid=[^&]*(?:&|$)/, '$1'); // From theglobeandmail.com links
window_href = window_href.replace(/([&?])feature=(?:related|embed)/, '$1'); // For YouTube

// If the string ends with the '?' character (no more GET variables left), remove it
window_href = window_href.replace(/\?$/, '');
window_href = window_href.replace(/[&?]$/, '');

// If the href has changed, update it
if (window.location.href != window_href) {
Expand Down

0 comments on commit 3eaeb98

Please sign in to comment.