3
1
51
collect
Report
share

利用Tampermonkey(油猴)快速关闭特定页面
The executable files mentioned in this article may require the ons emulator plugin to run on mobile devices (Android, iOS, HarmonyOS, etc.) or other platforms. If needed, please download the required plugins or features from the Common Plugins mini-program within the VikACG App.
-
说明
- 推荐仅用于部分网站的新标签页式广告,页面内广告请考虑使用AdBlock,AdGuard等
- 具体用于何处本人概不负责
- 以下教程均以FireFox为例
-
初始准备
-
使用国际主流浏览器, Chrome、Microsoft Edge、Safari、Opera Next 或 Firefox;不要用2345之类的不可名状之物
-
安装Tampermonkey
-
一双手
-
至少有Ctrl,C,V键的键盘
-
鼠标或触控板
-
安装Tampermonkey
这部分在我之前的文章<OneDrive高速/离线下载>中有提及,就不再赘述了
-
创建第一个自己的用户脚本
1.只需点击工具栏上的
图标(注:这里使用的是BETA版本,如果是普通版本则图标应该是灰色的,理论上也可以正常使用)
2.直接点击图中红框部分

3.理论上应该看到类似下面的样子

说明:
注释使用 // 符号,下面没有中文说明的部分都是在这里不太重要的东西
// ==UserScript==
// @name New Userscript //脚本名字
// @namespace Web links(tampermonkey.net)
// @version 0.1 //脚本版本
// @description try to take over the world! //脚本说明
// @author You //作者名
// @match https://www.vikacg.com/creator/write/post //作用域,可以理解为在哪些地方可以生效,支持通配符"*"
// @icon https://icons.duckduckgo.com/ip2/vikacg.com.ico //图标
// @grant none
// ==/UserScript==
而其中注释了// Your code here...的,很明显,我们的代码应该写在这之中
-
那么,开写!
事实上这功能的实现非常非常简单,已知,下面这行代码的效果是立即关闭页面,那我们所需要做的,就是让它正常的生效在我们需要的位置(广告网页)
setTimeout(() => {window.close();}, 0);
那么,就有非常非常简单的方法可以做到,还记得前面的@match吗?
我们只需要简单的将它修改成我们想要关闭的页面的URL就行了,像下面这样(还顺便更改了一下图标)
// @match Web links(pan.baidu.com)
// @icon https://icons.duckduckgo.com/ip2/baidu.com.ico
这样,当访问到像是Web links(pan.baidu.com)这样的网页时,网页就会被立即关闭 (千万别作死写成*://*这样会导致绝大多数页面被直接关闭!!! 除非后面有判定执行)
以及,@match可以添加多个,还需要自动关闭就自己加就好了~
-
完整示例代码以及其他应用
Hide content, please check it after Log in
N friends have already viewed unlocked content, and all points are available on this site for free. Come and register.
Download content
Current locked content may contain download files, please unlock to view the full text
Hide content, please check it after Log in
N friends have already viewed unlocked content, and all points are available on this site for free. Come and register.
DeclarationAll articles on this site, unless otherwise indicated or marked, are original publications of this site. Any individual or organization is prohibited from copying, stealing, collecting, or publishing the content of this site to any website, book, or other media platform without the consent of the author. If the content of this site infringes upon the legitimate rights and interests of the original author, please contact us for processing: DMCA Report
Follow Us













This guy seems to be very shy (bushi
This guy seems to be very shy (bushi
This guy seems to be very shy (bushi
A
This guy seems to be very shy (bushi
This guy seems to be very shy (bushi
This guy seems to be very shy (bushi
This guy seems to be very shy (bushi
哈啰大家,這裡是墨狐,偶爾會丟點東西上來 通用密码:工口、inkfox
This guy seems to be very shy (bushi
工作太忙,随缘更新
This guy seems to be very shy (bushi
This guy seems to be very shy (bushi
This guy seems to be very shy (bushi
This guy seems to be very shy (bushi
This guy seems to be very shy (bushi
This guy seems to be very shy (bushi
This guy seems to be very shy (bushi
This guy seems to be very shy (bushi
This guy seems to be very shy (bushi