Skip to content

Instantly share code, notes, and snippets.

@linkdesu
Last active Sep 27, 2019
Embed
What would you like to do?
Summon eruda devtool when you cast the spell.
;(function () {
var step = 0
function load (url, callback) {
var script = document.createElement('script');
script.src = url;
script.onload = callback;
document.body.appendChild(script);
}
function summonEruda (e) {
if (e.target.dataset && e.target.dataset.summonEruda) {
step++
if (step >= 8) {
load('//cdn.jsdelivr.net/npm/eruda', function () {
eruda.init()
load('//cdn.jsdelivr.net/npm/eruda-dom', function () {
eruda.add(erudaDom);
})
})
document.body.removeEventListener('click', summonEruda)
}
}
}
document.body.addEventListener('click', summonEruda)
})()
@linkdesu
Copy link
Author

linkdesu commented Sep 27, 2019

The repo of eruda devtool: https://github.com/liriliri/eruda
The spell: add attribute data-summon-eruda="true" to any element, then click it for more than 8 times.
minified:

!function(){var d=0;function t(e,n){var d=document.createElement("script");d.src=e,d.onload=n,document.body.appendChild(d)}document.body.addEventListener("click",function e(n){n.target.dataset&&n.target.dataset.summonEruda&&8<=++d&&(t("//cdn.jsdelivr.net/npm/eruda",function(){eruda.init(),t("//cdn.jsdelivr.net/npm/eruda-dom",function(){eruda.add(erudaDom)})}),document.body.removeEventListener("click",e))})}();

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment