油猴脚本@match正则匹配问题


今天尝试学写一个油猴脚本,编写 @match 域名匹配规则正则,通过工具测试该规则验证无误,如图

油猴脚本@match正则匹配问题

但是运到油猴后,页面始终无法触发脚本

图中 file:///E:\demo\Tampermonkey\demo.js 目录文件内容为:

(function () {
 console.log('天健,君子以自强不息!!!')
})();

请问是为什么呢,还望解答,谢谢!

回答

写的真复杂,这匹配没那么麻烦

参考下别人写的,*://*.csdn.net/*

或者

// @match *://blog.csdn.net/*/article/details/*
// @match *://*.blog.csdn.net/article/details/*
// @match *://bbs.csdn.net/topics/*
// @match *://*.iteye.com/blog/*