Last active
June 9, 2018 05:09
-
-
Save GaurangTandon/b85db9c85d6499df69b584357ab3dabb to your computer and use it in GitHub Desktop.
SO question
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 Demobug | |
// @version 0.1 | |
// @description Demo bug | |
// @author https://stackoverflow.com/users/2675672/gaurang-tandon | |
// @match *://*.stackoverflow.com/* | |
// @grant none | |
// ==/UserScript== | |
(function() { | |
'use strict'; | |
function createModal(buttonBar){ | |
var div = document.createElement("div"), | |
input = document.createElement("input"), | |
btn = document.createElement("button"); | |
div.id = "box"; | |
input.type = "text"; | |
btn.innerHTML = "Button"; | |
btn.onclick = function(e){ | |
e.preventDefault(); | |
console.log("I was called"); | |
input.focus(); | |
console.dir(e); | |
console.trace(); | |
}; | |
div.appendChild(input); | |
div.appendChild(btn); | |
return div; | |
} | |
setInterval(function () { | |
var cont = document.querySelector(".wmd-container:not(.processed)"), ul, buttonBar, div; | |
if (cont && (ul = cont.querySelector(".wmd-button-bar ul"))) { | |
cont.classList.add("processed"); | |
buttonBar = cont.querySelector("div[id^=wmd-button-bar]"); | |
div = createModal(buttonBar); | |
buttonBar.appendChild(div); | |
} | |
}, 500); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment