Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.