什么是 userscript

按照 https://greasyfork.org/en 网站的描述:

User scripts put you in control of your browsing experience. Once installed, they automatically make the sites you visit better by adding features, making them easier to use, or taking out the annoying bits. The user scripts on Greasy Fork were written by other users and posted to share with the world. They’re free to install and easy to use.


user script manager

如果需要在浏览器使用 user script,需要安装 userscript manager,比如 Chrome 可以安装 Tampermonkey

如何编写自己的 userscript

在 Tampermonkey 扩展上菜单选择「Create a new script」,出现如下所示的代码片段,就可以开始编写了。

// ==UserScript==
// @name         New Userscript
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  try to take over the world!
// @author       You
// @match        https://greasyfork.org/en
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    // Your code here...


  1. 语法就是 javascript
  2. 脚本将会在页面加载完毕后开始执行