Advertisement
BigBisous

Youtube Parameters Stripper

Dec 13th, 2016
47
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // ==UserScript==
  2. // @name        Youtube Parameters Stripper
  3. // @namespace   lehollandaisvolant.net
  4. // @description Removes ?feature* parametes on Youtube
  5. // @include     http://*.youtube.com/watch*
  6. // @include     https://*.youtube.com/watch*
  7. // @version     1
  8. // ==/UserScript==
  9. (function () {
  10.   var sp = window.location.search.replace(/^\?/, '').split('&'),
  11.   sk = [
  12.   ];
  13.   for (var i = 0; i < sp.length; i++) {
  14.     if (!/^(?:feature|annotation_id|src_vid|NR)$/i.test(sp[i].split('=') [0])) {
  15.       sk.push(sp[i]);
  16.     }
  17.   }
  18.   var newurl = window.location.protocol + '//' + window.location.host
  19.   + window.location.pathname + (sk.length ? '?' + sk.join('&')  : '')
  20.   + window.location.hash;
  21.   if (newurl != window.location.href) {
  22.     (!!(window.history && window.history.pushState)
  23.     ? window.history.pushState(null, null, newurl)
  24.     : window.location.replace(newurl)
  25.     );
  26.   }
  27. }) ();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement