Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jerrylususu/mainonly
A JavaScript bookmarklet designed to isolate and highlight a specific element on a webpage, effectively hiding all other elements.
https://github.com/jerrylususu/mainonly
Last synced: 14 days ago
JSON representation
A JavaScript bookmarklet designed to isolate and highlight a specific element on a webpage, effectively hiding all other elements.
- Host: GitHub
- URL: https://github.com/jerrylususu/mainonly
- Owner: jerrylususu
- License: mit
- Created: 2023-12-16T16:34:23.000Z (11 months ago)
- Default Branch: main
- Last Pushed: 2024-02-04T12:28:26.000Z (9 months ago)
- Last Synced: 2024-06-01T02:32:52.417Z (5 months ago)
- Language: JavaScript
- Homepage: http://nekonull.me/mainonly/
- Size: 3.1 MB
- Stars: 157
- Watchers: 3
- Forks: 13
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# mainonly
[Intro Page](https://nekonull.me/mainonly/)
A JavaScript bookmarklet designed to isolate and highlight a specific element on a webpage, effectively hiding all other elements.
(Created with GPT-4-turbo-1106 and refined through manual adjustments.)
![demo](mainonly.gif)
## How to Use
1. Copy the following code:
```JavaScript
javascript:(function(){document.getElementById("mainonly")&&document.dispatchEvent(new KeyboardEvent("keydown",{key:"Escape"}));var e=document.body,n=null;e.id?(n="class",e.classList.add("mainonly")):(n="id",e.id="mainonly");let t=document.head.appendChild(document.createElement("style"));t.textContent="#mainonly { outline: 2px solid red; } .mainonly { outline: 2px solid red; }";let i=document.body.appendChild(document.createElement("div"));i.className="mainonly-guide",i.innerHTML=`正在选择元素。按 Esc 键取消选择。向下滚动,或按下 =/. 键缩小选区。向上滚动,或按下 -/, 键扩大选区。
Selecting element. Press Esc to cancel selection. Scroll down, or press =/. to shrink the selection. Scroll up, or press -/,, to expand the selection.
`;let o=document.head.appendChild(document.createElement("style"));function l(t){t instanceof HTMLElement&&("id"===n?e.removeAttribute("id"):e.classList.remove("mainonly"),(e=t).id?(n="class",e.classList.add("mainonly")):(n="id",e.id="mainonly"))}function d(e){l(e.target)}function a(i){i.preventDefault(),function n(){for(var t=e;t.parentElement;)(t=t.parentElement).classList.add("mainonly_parents")}(),"id"===n?t.textContent="* { visibility: hidden; } #mainonly, #mainonly *, .mainonly_parents { visibility: visible; }":t.textContent="* { visibility: hidden; } .mainonly, .mainonly *, .mainonly_parents { visibility: visible; }",m(),r()}function r(){i.remove(),o.remove()}function s(i){if("Escape"===i.key)t.remove(),document.removeEventListener("keydown",s),m(),r(),"id"===n?e.removeAttribute("id"):e.classList.remove("mainonly"),function e(){for(var n=document.querySelectorAll(".mainonly_parents"),t=0;t正在选择元素。按 Esc 键取消选择。向下滚动,或按下 =/. 键缩小选区。向上滚动,或按下 -/, 键扩大选区。Selecting element. Press Esc to cancel selection. Scroll down, or press =/. to shrink the selection. Scroll up, or press -/,, to expand the selection.
`;let o=document.head.appendChild(document.createElement("style"));function l(t){t instanceof HTMLElement&&("id"===n?e.removeAttribute("id"):e.classList.remove("mainonly"),(e=t).id?(n="class",e.classList.add("mainonly")):(n="id",e.id="mainonly"))}function d(e){l(e.target)}function a(i){i.preventDefault(),function n(){for(var t=e;t.parentElement;)(t=t.parentElement).classList.add("mainonly_parents")}(),"id"===n?t.textContent="* { visibility: hidden; } #mainonly, #mainonly *, .mainonly_parents { visibility: visible; }":t.textContent="* { visibility: hidden; } .mainonly, .mainonly *, .mainonly_parents { visibility: visible; }",m(),r()}function r(){i.remove(),o.remove()}function s(i){if("Escape"===i.key)t.remove(),document.removeEventListener("keydown",s),m(),r(),"id"===n?e.removeAttribute("id"):e.classList.remove("mainonly"),function e(){for(var n=document.querySelectorAll(".mainonly_parents"),t=0;t