Advertisement
Guest User

Disable Polymer YouTube - Userscript

a guest
Aug 29th, 2017
576
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // ==UserScript==
  2. // @name        Disable Polymer YouTube
  3. // @match       *://*.youtube.com/*
  4. // @run-at      document-start
  5. // @grant       none
  6. // ==/UserScript==
  7.  
  8. //Not the fastest, but please improve as you see fit.
  9.  
  10. try {
  11.     var url = document.location.toString();
  12.     var updateUrl = updateQueryStringParameter(url, 'disable_polymer', 'true');
  13.     console.log(updateUrl);
  14.     console.log(url != updateUrl);
  15.     if (url != updateUrl) {
  16.         document.location = updateUrl;
  17.     }
  18. } catch (e) {}
  19.  
  20. function updateQueryStringParameter(uri, key, value) {
  21.     var re = new RegExp("([?&])" + key + "=.*?(&|$)", "i");
  22.     var separator = uri.indexOf('?') !== -1 ? "&" : "?";
  23.     if (uri.match(re)) {
  24.         return uri.replace(re, '$1' + key + "=" + value + '$2');
  25.     } else {
  26.         return uri + separator + key + "=" + value;
  27.     }
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement