Last active
August 29, 2015 14:20
-
-
Save bo33b/518688b79ecc98be8e1b to your computer and use it in GitHub Desktop.
Disable TP-LINK router web interface location redirects and context menu blocking userscript for Greasemonkey
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name No TP-LINK Lockouts | |
// @namespace bo33b | |
// @description Re-enable router web interface blocked actions. | |
// @downloadURL https://gist.github.com/bo33b/518688b79ecc98be8e1b/raw/tplink.user.js | |
// @include http://192.168.1.1/userRpm/* | |
// @include http://www.tp-link.com/resources/simulator/* | |
// @version 1.0 | |
// @grant none | |
// @run-at document-start | |
// ==/UserScript== | |
function interceptScript(ev) { | |
var script = ev.target, | |
code = script.textContent; | |
if (code.contains('.location=') || code.contains('.location =') || code.contains('document.oncontextmenu')) { | |
var newScript = document.createElement('script'); | |
newScript.innerHTML = cleanse(script.innerHTML); | |
ev.stopPropagation(); | |
ev.preventDefault(); | |
script.parentNode.insertBefore(newScript, script.nextSibling); | |
script.parentNode.removeChild(script); | |
} | |
} | |
function cleanse(script) { | |
for (var s = script.split('\n'), l = s.length, i = 0; i < l; i++) { | |
if (s[i].contains('.location=') || s[i].contains('.location =') || s[i].contains('document.oncontextmenu')) { | |
s[i] = ';'; | |
} | |
} | |
return s.join('\n'); | |
} | |
document.addEventListener("beforescriptexecute", interceptScript, true); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment