网站建设费用模板掼蛋网站建设
目录
- 新建用户脚本
 - 模板
 - 源注释
 
- 测试代码
 - 获取图标
 
Tampermonkey v4.19.0
  原教程:手写油猴脚本,几分钟学会新技能——王子周棋洛
   Tampermonkey首页
   面向 Web 开发者的文档
   Greasy Fork
新建用户脚本
打开【管理面板】
 
 点击【+】,即可新建一个用户脚本
 
 
模板
// ==UserScript==
// @name         New Userscript
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  try to take over the world!
// @author       You
// @match        https://www.bilibili.com/
// @icon         https://www.google.com/s2/favicons?sz=64&domain=bilibili.com
// @grant        none
// ==/UserScript==(function() {'use strict';// Your code here...
})();
 
源注释
用于被油猴插件读取,
// ==UserScript==
// @name         New Userscript					脚本名
// @namespace    http://tampermonkey.net/		无用
// @version      0.1							版本号
// @description  try to take over the world!	描述
// @author       You							作者
// @match        https://www.bilibili.com/		匹配原则,脚本要在哪些网页生效
// @icon         https://www.google.com/s2/favicons?sz=64&domain=bilibili.com	脚本图标
// @grant        none
// ==/UserScript==
 
测试代码
// ==UserScript==
// @name         New Userscript
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  try to take over the world!
// @author       You
// @match        https://blog.csdn.net/*/article/details/*
// @icon         https://g.csdnimg.cn/static/logo/favicon32.ico
// @grant        none
// ==/UserScript==//获取所有代码块
let codes = document.querySelectorAll("code");
//循环遍历所有代码块
codes.forEach(c => {
//设置代码块可以编辑,从而实现可复制
c.contentEditable = "true";
});
 
获取图标
F12后在【网络】搜索".ico"刷新网页,即可获取到相应的对象:
 
 选择标头,可见其URL为 https://g.csdnimg.cn/static/logo/favicon32.ico
 
