0

i wanted to change youtube to normal style. and i have come with the idea that the normal overlay, has an "&disable_polymer=true" at the end. so i tried using tampermonkey to change every site on youtube to be with an &disable_polymer=true at the end. here is what i came up with:

// ==UserScript==
// @name         New Userscript
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  try to take over the world!
// @author       You
// @match        https://www.youtube.com/*
// @grant        none
// ==/UserScript==
var currentLocation = window.location;
window.location.replace(window.location + "&disable_polymer=true");

but the issue is, (and you can try it yourself) tampermonkey will just repeatedly put &disable_polymer=true in a loop because youtube.com/* includes youtube.com/&disable_polymer=true so the site now becomes: "http://www.youtube.com/&disable_polymer=true&disable_polymer=true**&disable_polymer=true** can anyone help me with this? and please dont steal my idea

ori6151
  • 592
  • 5
  • 11

1 Answers1

1

Just check if it contains that string first..

if(!window.location.toString().toLowerCase().contains("disable_polymer")){
     window.location.replace(window.location + "&disable_polymer=true")
}
Matti Price
  • 3,351
  • 15
  • 28