Skip to content

Instantly share code, notes, and snippets.

@yudoufu
Forked from wozozo/remove-utm.txt
Created January 30, 2012 15:03
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save yudoufu/1704865 to your computer and use it in GitHub Desktop.
Save yudoufu/1704865 to your computer and use it in GitHub Desktop.
utmのパラメータをURLから取り除くブックマークレットとuser.js
javascript:(function(){var e,d,b,c,a;d=location;b=d.search.replace(/^\?/,'').split('&');c=[];a=b.length;while(a--){if(!b[a].match(/^utm_/)){c.push(b[a])}else{e=true}}if(e){d.href=d.pathname+((c.length)?'?'+c.join('&'):'')}})();
/**
* Remove utm parameters from url
* ( Use this as bookmarklet )
*/
(function(){
var search, params, i, re;
search = location.search.replace( /^\?/, '' ).split( '&' );
params = [];
i = search.length;
while( i-- ){
if( !search[i].match( /^utm_/ ) ){
params.push( search[i] );
} else {
re = true;
}
}
if (re) {
history.pushState('','',location.pathname + (( params.length ) ? '?' + params.join( '&' ) : '' ));
}
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment