Skip to content

Instantly share code, notes, and snippets.

@wozozo
Forked from yudoufu/remove-utm.txt
Last active September 30, 2015 03:37
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wozozo/1714762 to your computer and use it in GitHub Desktop.
Save wozozo/1714762 to your computer and use it in GitHub Desktop.
utmのパラメータをURLから取り除くuser.js
/**
* Remove utm parameters from url
* ( Use this as bookmarklet )
*/
(function(){
var search, params, i, re;
search = location.search.replace( /^\?/, '' ).split( '&' );
params = [];
if (!search) return;
i = search.length;
while( i-- ){
if( !search[i].match( /^utm_|^fb_action|^fb_source|^action_object_map|^action_type_map|^action_ref_map/ ) ){
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