Last active
August 25, 2018 22:10
-
-
Save CarbonAlabel/69f795fd80e73c95acd43f7f8915c362 to your computer and use it in GitHub Desktop.
EVE Developers scope search box bookmarklet (source)
This file contains 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
document.head.appendChild(document.createElement("style")).innerHTML = ".scopeSearchHidden{display:none !important}" + | |
".scopeSearchInput{width:270px;display:block;padding:1px;border:1px solid #ccc;border-bottom:0;border-radius:3px 3px 0 0;box-shadow:inset 0 1px 1px rgba(0,0,0,0.075);}" + | |
".scopeMultiClick{width:270px;display:block;padding:1px;border:1px solid #ccc;border-top:0;border-radius:0 0 3px 3px;box-shadow:inset 0 1px 1px rgba(0,0,0,0.075);}" + | |
".ms-container .ms-list{margin-bottom:0 !important;border-radius:0 !important;}"; | |
const scopeSearch = (s, e) => { | |
e.querySelectorAll("li").forEach(e => e.innerText.indexOf(s) > -1 ? e.classList.remove("scopeSearchHidden") : e.classList.add("scopeSearchHidden")); | |
}; | |
const clickAll = (e) => { | |
e.querySelectorAll("li").forEach(e => { | |
if (e.style.display !== "none" && !e.classList.contains("scopeSearchHidden")) { | |
e.click(); | |
} | |
}); | |
}; | |
document.querySelectorAll("#ms-scopes>div").forEach(e => { | |
e.querySelector(".scopeSearchInput").remove(); | |
let s = document.createElement("input"); | |
s.className = "scopeSearchInput"; | |
s.oninput = () => scopeSearch(s.value, e); | |
e.insertBefore(s, e.childNodes[1]); | |
let c = document.createElement("button"); | |
c.type = "button"; | |
c.className = "scopeMultiClick"; | |
c.onclick = () => clickAll(e); | |
c.innerText = {"ms-selectable": "Add all shown", "ms-selection": "Remove all shown"}[e.className]; | |
e.insertBefore(c, null); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment