浏览器扩展
用户脚本
用户脚本(我们也称之为「扩展」)实质上是用 JavaScript 编写的小程序。 用户脚本修改或扩展一个或多个网站的功能。 许多 AdGuard 用户已经熟悉 AdGuard 助手、弹窗拦截器和 AdGuard Extra 等用户脚本。
AdGuard 可作为用户脚本管理器以显著扩展网站功能。 You can add your custom scripts or manage the existing ones in our three products: AdGuard for Windows, AdGuard for Android, and AdGuard for Mac.
推荐的 AdGuard 脚本
AdGuard 开发人员创建这些用户脚本,我们可以保证它们有效且安全。 For some of the userscripts developed by others that we consider good and reliable, scroll down to the next section. You can also find some of the popular websites with scripts below, but remember that whenever you download a userscript from an unknown source, you are exposing yourself to a certain risk, as some scripts may be harmful to your computer.
AdGuard Extra
该扩展可以在通常的过滤方法无法解决问题的情况下屏蔽广告。 AdGuard Extra comes pre-installed in AdGuard standalone apps, except for the one for iOS, so you don't need to do anything to enable it. 不过,如果有用户想将 AdGuard Extra 与 AdGuard 浏览器扩展或其他广告拦截器一起使用,需要使用一个额外的扩展。 Learn more about this userscript and how to install it on GitHub.
AdGuard 弹窗拦截器
The name speaks for itself: it blocks popups — one of the most annoying types of ads on websites. Learn more about this userscript, its key features, and installation on GitHub.
AdGuard 助手(旧版)
This custom extension is designed to control filtering directly from the browser page (manual blocking, allowlisting, etc.).
This version of Assistant is legacy and there is no point in using it on new systems, as it has been replaced with the full-fledged Browser Assistant. However, the legacy Assistant may be useful if there is no Browser Assistant for your browser. If this is your case, you can learn how to install AdGuard Assistant on GitHub.
禁用 AMP
这是一个仅在 Android 版 AdGuard 中预安装的脚本。 它禁用 Google 搜索结果页面上的 AMP(加速移动页面)。 Learn more about this userscript and how to install it on GitHub.
AdGuard 以外的最佳脚本选择
These userscripts are not developed by AdGuard, and therefore we can't give a 100% guarantee that they are safe and/or work at all times. However, in our experience they deserve a recommendation because they've all earned their good reputation.
Don't track me Google
该脚本移除 Google 搜索结果中链接的 Google 跟踪功能。 它加快搜索结果的加载速度,允许用户右键单击或点击复制链接 URL。
Its source code is available on GitHub. This userscript can be downloaded from GreasyFork and installed in any AdGuard CoreLibs-based app.
microShield
A userscript for people visiting Korean websites and some international websites. The microShield userscript blocks Ad-Shield ads and anti-adblocks. Its original source code is available at asdefuser and AdShield Defuser. This userscript can be installed in AdGuard CoreLibs-based apps, Violentmonkey, Tampermonkey, and quoid/userscripts. Learn more about microShield and how to install it on GitHub.
在哪里查看更多自定义脚本
Since userscripts are mainly created by enthusiasts, you should be cautious when installing them. 任何来源不明的脚本都有潜在风险。 不过,也有大量有用的脚本。如果认真负责地选择,确实可以使网页更易于浏览。
下面我们将介绍一些最常用的用户脚本。
Userscript.Zone
Userscript.Zone is a website that allows searching for userscripts by entering a matching URL or domain. The website is easy to use and has a high level of credibility as only scripts from moderated pages are displayed.
Greasy Fork
Greasy Fork is a userscript catalog of Stylish creators. The scripts in this catalog are moderated, so their credibility is much higher.
OpenUserJS.org
OpenUserJS.org is an open-source userscript catalog written in nodeJS. It's not moderated, so keep an eye out for suspicious scripts.
社区
If you like the idea of customizing your browser with userscripts and have questions, you can ask them on one of these websites:
开发
申请许可证
If you are developing your own custom script and want to test how it works with AdGuard, you can request a beta license key for the app.
要获取许可证,请发送电子邮件至 devteam@adguard.com 并附上以下信息:
Subject: Userscript author license request
Body: Please tell us about the userscripts you are working on.
Here is a mailto link.
兼容性
元数据块
支持的属性
@name
@namespace
@description
@version
@match
@include
@exclude
@grant
@connect
@require
@resource
@downloadURL
@updateURL
@supportURL
@homepageURL
@homepage
@website
@source
@run-at
@noframes
@icon
@iconURL
@defaulticon
@icon64
@icon64URL
不支持的属性
AdGuard 将忽略这些属性。
@unwrap
支持的 GM 函数
AdGuard 同时支持旧的 GM_ 函数和使用 GM 对象的新 GM4 API。
数值
所有列出的旧 Greasemonkey 函数都已过时,但仍受支持。
GM.info / GM_info
GM.setValue / GM_setValue
GM.getValue / GM_getValue
GM.listValues / GM_listValues
GM.deleteValue / GM_deleteValue
GM.getResourceUrl / GM_getResourceURL
GM.setClipboard / GM_setClipboard
GM.xmlHttpRequest / GM_xmlhttpRequest
GM.openInTab / GM_openInTab
GM.notification
unsafeWindow
GM_getResourceText
GM_addStyle
GM_log
Here you can find more information about Greasemonkey API.
示例
// ==UserScript==
// @name Name as shown to the user when locale is english or unknown
// @name:ru Name as shown to the user when locale is russian
// @description Description as shown to the user when locale is english or unknown
// @description:ru Description as shown to the user when locale is russian
// @icon https://myhomepage.com/myuserscript.png
// @version 1.0.0.0
// @downloadURL https://dl.myhomepage.org/myuserscript.user.js
// @updateURL https://dl.myhomepage.org/myuserscript.meta.js
// @homepageURL https://myhomepage.com/myuserscript
// @include *
// @exclude *://website.com/*
// @resource https://myhomepage.com/myuserscript.css
// @require https://myhomepage.com/mylibrary.js
// @grant property:settings
// @grant GM_getValue
// @grant GM_setValue
// @grant GM_deleteValue
// @grant GM_listValues
// @grant GM_getResourceText
// @grant GM_getResourceURL
// @grant GM_addStyle
// @grant GM_log
// @grant GM_setClipboard
// @grant GM_xmlhttpRequest
// @grant unsafeWindow
// @grant GM_info
// @grant GM_openInTab
// @grant GM_registerMenuCommand
// @run-at document-start
// ==/UserScript==
!function(){(
console.log("I am loaded!");
)}();
用户样式
Userstyles allow users to customize their online experience. Whether you’re looking to change the appearance of a website or automate repetitive tasks, styles offer a world of possibilities.
AdGuard has the option to upload or create your own userstyles. This is an advanced feature, so you will need some knowledge of HTML and CSS.
Currently, two AdGuard apps allow you to create and manage userstyles: AdGuard for Windows (v7.19 or later) and AdGuard for Mac (v2.16 or later). We also plan to implement this new feature in AdGuard v4.8 for Android in the nearest future.
This is an experimental feature, so if you encounter any problems while adding or creating a userstyle, please contact our support team at support@adguard.com.
How to set up a userstyle in AdGuard
You can download userstyles from various websites. One of the most popular userstyle websites is https://userstyles.world/, which we will use as an example for the following instructions on how to set up the userstyle in AdGuard.
Follow the link above and choose the userstyle you like
Right-click the Install button and choose Copy Link Address
Open AdGuard settings → Extensions
Press the [+] button and paste the userstyle link
完成!
If you’re familiar with CSS rules, you can also create the userstyles yourself.
We don’t support userstyles that contain @var
or @advanced
in the metadata. AdGuard also doesn’t support @preprocessor
without the default
value.
Open AdGuard settings → Extensions
Press the [+] button and choose the Create userstyle option. A new window will appear on your screen
To create a userstyle, first write the title with metadata, for example
/* ==UserStyle==
@name New userstyle
@version 1.0
==/UserStyle== */Write the CSS part after the meta data. AdGuard supports website domain names matching (
@-moz-document domain(…), …
). For example:body {
background: gray;
}Or:
@-moz-document domain('example.org'),
domain('example.net'),
domain('example.com') body {
background: gray;
}Once you’re finished, press Save and Close. Your new userstyle has been successfully added to AdGuard
示例
/* ==UserStyle==
@name Example userstyle
@namespace https://example.org/userstyle
@homepageURL https://example.org/userstyle
@version 1.0.0
@license Other
@description This is an example
@author example
@preprocessor default
==/UserStyle== */
@-moz-document regexp("https?\:\/\/(www\.)?example\.(org|com).*") {
body {
background-color: #000000 !important;
}
}