我正在使用 Tampermonkey 在表单的每个页面上运行脚本:
https://markus.teach.cs.toronto.edu/csc413-2020-01/assignments/2/submissions/329/results/329/edit
一般结构在哪里
https://markus.teach.cs.toronto.edu/csc413-2020-01/assignments/2/submissions/#NUM/results/#NUM/edit
我尝试通过以下方式匹配此网址:
https://markus.teach.cs.toronto.edu/csc413-2020-01/assignments/2/*
,但此模板未触发脚本。
完整的脚本如下:
// ==UserScript==
// @name CSC413 autoscript
// @namespace http://tampermonkey.net/
// @version 0.1
// @description Automation
// @author II
// @match https://markus.teach.cs.toronto.edu/csc413-2020-01/assignments/2/*
// @grant none
// ==/UserScript==
(function() {
'use strict';
console.log("script running");
//code here
console.log("finished execution");
})();
有人知道这是怎么回事吗?如果我使用通用的,它会匹配
@include https://*/*
最佳答案
您需要转义斜杠和点,因为它们在正则表达式中具有特殊含义。
并且您需要在星号前添加一个点。点表示任意一个字符。这位明星将其量化为“零个或更多”。 .*
计算一切。在您的代码中编写/*
。上面写着“零个或多个斜杠”
https:\/\/markus\.teach\.cs\.toronto\.edu\/csc413-2020-01\/assignments\/2\/.*
关于javascript - Tampermonkey 匹配所有子目录,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60469965/