「Userscript」:修訂間差異
跳至導覽
跳至搜尋
本頁面具有訪問限制。如果您看見此訊息,這代表您沒有訪問本頁面的權限。
無編輯摘要 |
(→外部連結) |
||
(未顯示同一使用者於中間所作的 17 次修訂) | |||
行 1: | 行 1: | ||
'''Userscript'''是一個讓開發者更容易操作(與修改)網頁的方式,通常是以[[JavaScript]]撰寫。 | '''Userscript'''是一個讓開發者更容易操作(與修改)網頁的方式,通常是以[[JavaScript]]撰寫。 | ||
== 軟體 == | |||
目前推薦使用開源的[[Violentmonkey]],支援[[Chromium]]系列瀏覽器,以及[[Firefox]]瀏覽器。 | |||
== 範例 == | == 範例 == | ||
對於SPA類常用的方式,聽HTML元素的事件: | === SPA === | ||
對於SPA類常用的方式,聽HTML元素的事件 (這邊是聽<code>document</code>元素,可以自己考慮聽更小的範圍) : | |||
<syntaxhighlight lang="javascript"> | <syntaxhighlight lang="javascript"> | ||
const ob = new window.MutationObserver(mutations => { | |||
mutations.forEach(mutation => { | |||
mutation.addedNodes.forEach(node => { | |||
if (...) { | |||
// Uninstall | |||
ob.disconnect(); | |||
} | |||
}); | }); | ||
}); | |||
}); | }); | ||
ob.observe(document, { | ob.observe(document, { | ||
childList: true, | |||
subtree: true, | |||
}); | }); | ||
</syntaxhighlight> | </syntaxhighlight> | ||
== 自用 == | |||
重新安裝時用的,自己寫的就不列出來了: | |||
* https://greasyfork.org/en/scripts/12493-hacker-news-folding-subtrees | |||
* https://greasyfork.org/en/scripts/15261-facebook-sort-recent-newsfeed-by-default | |||
* https://greasyfork.org/en/scripts/23661-youtube-hd | |||
* https://greasyfork.org/en/scripts/383093-twitch-disable-automatic-video-downscale | |||
* https://greasyfork.org/en/scripts/394512-youtube-progressbar-preserver | |||
* https://greasyfork.org/en/scripts/396936-yt-not-interested-in-one-click | |||
* https://greasyfork.org/en/scripts/403045-dmhy-bangumi-current-season | |||
* https://greasyfork.org/en/scripts/431970-facebook-ad-block | |||
另外的一些: | |||
* https://adsbypasser.github.io/ | |||
== 外部連結 == | |||
* https://en.wikipedia.org/wiki/Userscript | |||
* https://greasyfork.org/en/users/13655-gslin | |||
=== Hosting === | |||
* https://greasyfork.org/ | |||
* https://openuserjs.org/ | |||
* https://sleazyfork.org/ |
於 2023年4月30日 (日) 19:31 的最新修訂
Userscript是一個讓開發者更容易操作(與修改)網頁的方式,通常是以JavaScript撰寫。
軟體
目前推薦使用開源的Violentmonkey,支援Chromium系列瀏覽器,以及Firefox瀏覽器。
範例
SPA
對於SPA類常用的方式,聽HTML元素的事件(這邊是聽document
元素,可以自己考慮聽更小的範圍):
const ob = new window.MutationObserver(mutations => {
mutations.forEach(mutation => {
mutation.addedNodes.forEach(node => {
if (...) {
// Uninstall
ob.disconnect();
}
});
});
});
ob.observe(document, {
childList: true,
subtree: true,
});
自用
重新安裝時用的,自己寫的就不列出來了:
- https://greasyfork.org/en/scripts/12493-hacker-news-folding-subtrees
- https://greasyfork.org/en/scripts/15261-facebook-sort-recent-newsfeed-by-default
- https://greasyfork.org/en/scripts/23661-youtube-hd
- https://greasyfork.org/en/scripts/383093-twitch-disable-automatic-video-downscale
- https://greasyfork.org/en/scripts/394512-youtube-progressbar-preserver
- https://greasyfork.org/en/scripts/396936-yt-not-interested-in-one-click
- https://greasyfork.org/en/scripts/403045-dmhy-bangumi-current-season
- https://greasyfork.org/en/scripts/431970-facebook-ad-block
另外的一些: