Last active
January 21, 2022 03:41
-
-
Save jasonsyoung/2661ab375efda4301fc6c1016abfdaaa to your computer and use it in GitHub Desktop.
User script to add Eruda to any page. Originally created for Adguard for Android.
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 Eruda Injector | |
// @version 1.9 | |
// @include * | |
// @description Injects Eruda onto any page | |
// @grant none | |
// ==/UserScript== | |
window.addEventListener('load', function () { | |
window.erudaParams = { | |
defaults: { | |
displaySize: 50, | |
transparency: 0.9, | |
theme: 'Monokai Pro' | |
} | |
}; | |
if (top.location === location && !window.eruda) { | |
var script = document.createElement('script'); | |
script.src = '//cdn.jsdelivr.net/npm/eruda'; | |
script.onload = function _onload() { | |
window.eruda.init(window.erudaParams); | |
window.eruda.get('console').config.set('displayIfErr', false); | |
window.eruda.get('console').config.set("displayExtraInfo", true); | |
}; | |
document.head.appendChild(script); | |
window.setTimeout(function _checkEruda() { | |
if (!window.eruda) { | |
var src = '//cdn.jsdelivr.net/npm/eruda'; | |
if (!/eruda=true/.test(window.location) && localStorage.getItem('active-eruda') != 'true') return; | |
document.write('<scr' + 'ipt src="' + src + '"></scr' + 'ipt>'); | |
document.write('<scr' + 'ipt>eruda.init(window.erudaParams);window.eruda.get("console").config.set("displayIfErr", false);window.eruda.get("console").config.set("displayExtraInfo", true);</scr' + 'ipt>'); | |
} | |
}, 5000, false); | |
} | |
}, false); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment