Created
February 20, 2024 12:54
-
-
Save Zazcallabah/4a116d78ed327c278eebf08646820f13 to your computer and use it in GitHub Desktop.
bookmarklet for some qol changes to infinitecraft
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
javascript: | |
(function(){ | |
var s = document.createElement("style"); | |
var css = [ | |
".nocandidate{background:#ddd !important}", | |
".container { position:static }", | |
".site-title {position:absolute}", | |
".sidebar {display:none}", | |
".mobile-items {", | |
"display:flex !important;", | |
"flex-wrap:wrap;", | |
"margin-top:105px;", | |
"justify-content:center;", | |
"grid-gap:5px 5px;", | |
"margin-bottom:20px;", | |
"padding:0 5px;", | |
"position:relative;", | |
"z-index:2", | |
"}", | |
".instance {display:none}", | |
".mobile-item { transition:transform .4s ease }", | |
".item {", | |
"display:flex;", | |
"align-items:center;", | |
"min-height:37px;", | |
"grid-gap:5px;", | |
"line-height:0;", | |
"font-size:15.5px;", | |
"padding:1px 9px 0;", | |
"border:1px solid #9f9f9f;", | |
"color:#000;", | |
"transition:background .1s linear", | |
"}", | |
".item-selected-mobile { top:5px }", | |
".item-crafted-mobile,", | |
".item-selected-mobile {", | |
"background-color:#fffae6;", | |
"border-color:#877f64;", | |
"position:sticky;", | |
"bottom:5px", | |
"}", | |
".item-crafted-mobile {", | |
"z-index:10;", | |
"transition:background .2s linear", | |
"}", | |
".side-controls,.sidebar-controls {display:none}" | |
]; | |
s.innerHTML = css.join("\n"); | |
document.head.appendChild(s); | |
localStorage.removeItem("inf-state"); | |
const gt = (e)=>{ | |
if(e?.target.className==="item-emoji-mobile"&&e?.target?.parentElement?.parentElement?.className==="mobile-item"){ | |
return e.target.parentElement; | |
} | |
if(e?.target?.parentElement?.className==="mobile-item"){ | |
return e.target; | |
} | |
return null; | |
}; | |
window.onclick=(e)=>{ | |
const t = gt(e); | |
if(t){ | |
if(localStorage["inf-state"]){ | |
console.log("second"); | |
var clikd = t.id; | |
var sld = localStorage["inf-state"]; | |
localStorage.removeItem("inf-state"); | |
var map = JSON.parse(localStorage["inf-history"] ??"{}"); | |
if(!map[clikd])map[clikd]=[]; | |
if(!map[sld])map[sld]=[]; | |
map[clikd].push(sld); | |
map[sld].push(clikd); | |
localStorage["inf-history"] = JSON.stringify(map); | |
var nc = document.getElementsByClassName("nocandidate"); | |
for(var i=0;i<nc.length;i++){ | |
nc[i].classList.remove('nocandidate'); | |
}; | |
} else { | |
console.log("first"); | |
var clikd = t.id; | |
localStorage["inf-state"]=clikd; | |
var map = JSON.parse(localStorage["inf-history"] ??"{}"); | |
var list = map[clikd] ?? []; | |
for(var i=0;i<list.length;i++){ | |
var nc = document.getElementById(list[i]); | |
if(nc){ | |
nc.classList.add('nocandidate'); | |
} | |
} | |
} | |
} else { | |
console.log("non-mobile-item"); | |
} | |
}; | |
})() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment