用户脚本有能力加载和执行其他脚本,方式包括:
虽然这是一个有用的功能,并且大多数脚本作者将其用在合法目的,但它也可以被恶意使用。Greasy Fork 的一项核心原则是,用户必须可能检查脚本中的代码。而外部脚本可能用多种方法绕过这一原则:它们可以在用户不知情的情况下悄悄改变,而不留下历史记录;它们可以对不同的用户采用不同的代码;它们还可以在知名的库之中插入恶意的代码,以期逃避用户的检查。因此,即便有人已检查了一个外部脚本,并确定它此时是安全的,也无法保证该脚本在过去和将来始终不含恶意代码。
允许的外部代码
为了允许脚本作者继续使用外部脚本,Greasy Fork 有一个 URL 形式的白名单,只允许引用白名单中的外部脚本。白名单中包含的网站应该是:
- 公开的
- 不频繁改变其内容的
- 可能被不止一位脚本作者取用的
如果您想加载的外部脚本是一个 JavaScript 库(例如 jQuery 或者 YUI),请访问上面列出的网站,看看是否能找到它的链接。cdnjs 和 jsDelivr 提供了大量的常用库。
目前的名单见:
75CDN |
^https:\/\/cdn\.baomitu\.com\/.*
|
|
75CDN |
^https:\/\/lib\.baomitu\.com\/.*
|
|
Baidu Analytics |
^https://hm\.baidu\.com/hm\.js.*
|
You must include @antifeature tracking if you use this. |
Baidu CDN |
^(https?:)?\/\/libs\.baidu\.com\/.*
|
|
Baidu CDN |
^https:\/\/apps\.bdimg\.com\/.*
|
|
Baidu CDN |
^https:\/\/code\.bdstatic\.com\/.*
|
|
BootCDN |
^https://cdn\.bootcdn\.net\/.*
|
|
Bootstrap中文网开放CDN服务 |
^(https?:)?\/\/cdn\.bootcss\.com\/.*
|
|
BowerCDN |
^https:\/\/bowercdn\.net\/.*
|
|
ByteDance |
^https:\/\/[^/]*\-cdn\-tos\.bytecdntp\.com\/cdn\/.*
|
|
cdn.kaskus.com |
^(https?:)?\/\/cdn\.kaskus\.com\/.*
|
|
cdnjs-hosted libraries |
^(https?:)?\/\/cdnjs\.cloudflare\.com\/.*
|
|
Firebase CDN |
^(https?:)?\/\/cdn\.firebase\.com\/.*
|
|
GitCDN (commit-specific URLS only) |
^https:\/\/(www\.)?gitcdn\.(xyz|link)\/(cdn|repo)\/[^/]+\/[^/]+\/[0-9a-f]{40}/.*$
|
|
gm4-polyfill |
^https:\/\/greasemonkey\.github\.io\/gm4\-polyfill\/gm4\-polyfill\.js(\?.*)?$
|
|
Google Analytics |
^https:\/\/ssl\.google\-analytics\.com\/ga\.js.*
|
You must include @antifeature tracking if you use this. |
Google Hosted Libraries on apis.google.com |
^https:\/\/apis\.google\.com\/.*
|
|
Google Hosted Libraries on googleapis.com |
^(https?:)?\/\/[a-z]+\.googleapis\.com\/.*
|
|
Google Maps API |
^(https?:)?\/\/maps\.google\.com\/maps\/api\/js.*
|
|
Google Tag Manager |
^https:\/\/www\.googletagmanager\.com\/gtag\/js.*
|
You must include @antifeature tracking if you use this. |
Google Translate |
^https:\/\/translate\.google\.com\/translate_a\/element\.js$
|
|
Google-hosted libraries on www.gstatic.com |
^https:\/\/www\.gstatic\.com\/.*
|
|
Greasy-Fork-hosted scripts (https://greasyfork.org/scripts/*.js) |
^(https?:)?\/\/greasyfork\.org\/scripts\/.+\.js.*
|
|
Greasy-Fork-hosted third party libraries on https://greasyfork.org/libraries/ |
^(https?:)?\/\/greasyfork\.org\/libraries\/.*
|
|
gwdang CDN |
^https:\/\/cdn\.gwdang\.com\/.*
|
|
gwdang_extension.js |
^https:\/\/browser\.gwdang\.com\/get\.js\?f=\/js\/gwdang_extension\.js$
|
|
Highcharts CDN |
^(https?:)?\/\/code\.highcharts\.com\/.*
|
|
jQuery on code.jquery.com |
^(https?:)?\/\/code\.jquery\.com/.*
|
|
jsDelivr GitHub commit-specific references |
^(https?:)?\/\/(cdn|test1|testingcf|fastly|gcore)\.jsdelivr\.net\/gh\/[^/]+\/[^/@]+@[a-f0-9]{40}
|
cdn.jsdelivr.net is the primary subdomain, but others are allowed in case of firewall blocks. |
jsDelivr npm version-specific references |
^(https?:)?\/\/(cdn|test1|testingcf|fastly|gcore)\.jsdelivr\.net\/npm\/.+@[0-9\.]+.*
|
cdn.jsdelivr.net is the primary subdomain, but others are allowed in case of firewall blocks. |
jsDelivr-hosted libraries |
^(https?:)?\/\/(cdn|test1|testingcf|fastly|gcore)\.jsdelivr\.net\/(?!(gh|npm)\/).*
|
cdn.jsdelivr.net is the primary subdomain, but others are allowed in case of firewall blocks. |
Layui |
https://www\.layuicdn\.com\/.*
|
|
LingoCloud |
^https:\/\/caiyunapp\.com\/dest\/trs\.js.*
|
|
MathJax CDN |
^(https?:)?\/\/cdn\.mathjax\.org\/.*
|
|
Microsoft Ajax CDN |
^(https?:)?\/\/ajax\.aspnetcdn\.com\/.*
|
|
Mousetrap |
^https:\/\/craig\.global\.ssl\.fastly\.net\/js\/mousetrap\/.*
|
|
OpenUserJS libraries |
^(https?:)?\/\/openuserjs\.org\/src\/libs\/.+\.js.*
|
|
Recaptcha |
^https://www\.google\.com/recaptcha/api\.js$
|
|
Sleazy-Fork-hosted scripts (https://greasyfork.org/scripts/*.js) |
^(https?:)?\/\/sleazyfork\.org\/scripts\/.+\.js.*
|
|
Sleazy-Fork-hosted third party libraries on https://greasyfork.org/libraries/ |
^(https?:)?\/\/sleazyfork\.org\/libraries\/.*
|
|
static.hdslb.com |
^(https?:)?\/\/static\.hdslb\.com\/.*
|
|
Todoist Anywhere |
^(https?:)?\/\/todoist\.com\/anywhere\/.*
|
|
unpkg |
^https:\/\/unpkg\.com/.*
|
|
Version-specific packd URLs |
^https:\/\/bundle\.run\/[^@]+@[0-9\.]+$
|
|
Wysibb CDN |
^(https?:)?\/\/cdn\.wysibb\.com\/.*
|
|
开放静态文件 CDN |
^(https?:)?\/\/cdn\.staticfile\.org\/.*
|
|
快手 CDN |
^https://static\.yximgs\.com/.*
|
URL 允许使用 URL 不允许使用
添加至列表
如果以上网站均没有您想引用的外部脚本,请告知我们,以便我们查找它的链接(乃至我们自己托管)。
如果您想包含的脚本是您自己写的,您可以在 Greasy Fork 上将它提交为一个单独的项目,选择“库”作为它的类型,然后就可以在您的脚本中引入这个您自己发布的库了。
特殊情況
除上述名单外,还允许使用:
- 加载网站现有的代码用于同一站点(例如在 example.com 上使用 example.com/script.js)。
- 仅供数据用途而加载一个资源,例如加载 JSON 文件而不执行它的内容。
禁止下列用法:
- 从外部 URL 加载对脚本的更新。
执法
任何被发现含有允许范围外的外部代码的脚本将被删除。