浏览器用户脚本管理器插件,用于安装开源脚本,也可以自己编写脚本。
自行编写脚本
- @match 匹配适用的网址,对所有网址适用则可为
://*/*
- @include 同@match
- @grant 默认为
none
,脚本将直接运行在网页。非none时将运行在沙箱环境,并可以使用对应的油猴扩展API - @require 在运行脚本前先导入其他js库
ES lint的全局变量报错可以如下代码解决:/* globals jQuery, $, waitForKeyElements */
一个用于隐藏油猴底部广告的demo脚本
// ==UserScript==
// @name tampermonkey no ads
// @namespace http://www.timeforus.cn/
// @version 0.1
// @description try to take over the world!
// @author Witty ME
// @match https://www.tampermonkey.net/*
// @match https://*/*
// @icon https://www.google.com/s2/favicons?sz=64&domain=tampermonkey.net
// @grant unsafeWindow
// @require http://code.jquery.com/jquery-1.11.0.min.js
// ==/UserScript==
/* globals jQuery, $, waitForKeyElements */
(function() {
'use strict';
console.log("This is Witty Me.I don't wanna see ads.");
$(".adsbygoogle").css('display','none');
})();
网友评论