// ==UserScript== // @name SimpCityLock // @namespace SimpCityLock // @version 0.1 // @description Try to take over the world! // @author emy // @match https://simpcity.su/* // @icon https://www.google.com/s2/favicons?sz=64&domain=simpcity.su // @grant none // ==/UserScript== const ignoreForReaction = false; const stopPropagation = (e) => { e.preventDefault(); e.stopImmediatePropagation(); }; const injectStyle = (css) => { const element = document.createElement('style'); let out = ''; for(const selector in css) { if(css.hasOwnProperty(selector)) { out += `${selector} {`; for(const property in css[selector]) { if(css[selector].hasOwnProperty(property)) { out += `${property}: ${css[selector][property]}; `; } } out += '} '; } } element.textContent = out; document.head.appendChild(element); }; (() => { for(const item of Array.from(document.querySelectorAll('a'))) { let onClick = null; if(ignoreForReaction && item.classList.contains('reaction')) { continue; } else if(item.classList.contains('thThreads__userExtra--trigger')) { onClick = (e) => { stopPropagation(e); const userParent = e.target.parentNode.parentNode; if(userParent) { const userExtras = userParent.querySelector(':scope > [class$="-userExtras"]'); if(userExtras) { userExtras.style.height = !userExtras.toggledExtra ? 'auto' : ''; userExtras.toggledExtra = !userExtras.toggledExtra; } e.target.classList.toggle('toggled'); } } } const newAnchor = item.cloneNode(true); item.parentNode.replaceChild(newAnchor, item); newAnchor.addEventListener('click', onClick || ((e) => { stopPropagation(e); if(item.tagName === 'A' && item.hasAttribute('href')) { window.location.href = newAnchor.getAttribute('href'); } })); } injectStyle({ '.thThreads__userExtra--trigger:not(.toggled)::before': { content: '"+"!important' }, '.thThreads__userExtra--trigger.toggled::before': { content: '"-"!important' }, 'ul > li > div > a[class*=" nav-"]': { display: 'none!important' } }) })();