Created
February 28, 2025 08:00
-
-
Save alsanan/78e804bef2fbcdc67f05bfcb86105333 to your computer and use it in GitHub Desktop.
Min Browser: Add your own CSS styles to the domain of the page so it applies at every load.
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 stylus | |
| // @version 0.1 | |
| // @description apply your styles to the current page | |
| // @author alsanan | |
| // @match * | |
| // @run-at document-start | |
| // ==/UserScript== | |
| /* instructions to start: | |
| 1. open console at devtools (F11) | |
| 2. enter: localStorage.setItem('stylus','/* */') | |
| 3. reload the page | |
| 4. again at console enter: stylusEdit() | |
| 5. write your css... it will be applied at posterior loads. | |
| */ | |
| (async () => { | |
| if (document.querySelector('style#stylus')) return; // ya estilado | |
| const stylus= localStorage.getItem('stylus') | |
| if (!stylus) return; | |
| console.log(stylus); | |
| // Crear y añadir una etiqueta <style> con los estilos aplicables | |
| const style = document.createElement('style'); | |
| style.setAttribute('id','stylus'); | |
| style.textContent = stylus; | |
| document.head.appendChild(style); | |
| window.stylusSave= ()=> { | |
| const stylus= document.querySelector('#stylusedit>textarea').value; | |
| localStorage.setItem('stylus',stylus); | |
| document.getElementById('stylus').innerText= stylus; | |
| document.getElementById('stylusedit').close(); | |
| } | |
| window.stylusEdit= ()=> { | |
| let st= style; | |
| document.body.innerHTML+=` | |
| <dialog id="stylusedit" style="width:90vw;height:90vh;z-index:999;"> | |
| <textarea autofocus style="position:absolute;inset:0;padding:1rem;" spellCheck="false">${stylus}</textarea> | |
| <button style="position: fixed; top: 4rem; right: 5rem;" onclick="stylusSave()">save</button> | |
| <button style="position: fixed; top: 4rem; right: 8rem;" onclick="document.getElementById('stylusedit').close()">cancel</button> | |
| </dialog> | |
| <button style="position:fixed; right:1rem; top:1rem;" onclick="document.getElementById('stylusedit').showModal()">editar</button> | |
| `; | |
| document.getElementById('stylusedit').showModal(); | |
| } | |
| })(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment