// ==UserScript== // @name 检测特定URL2 // @namespace http://tampermonkey.net/ // @version 1.0.2 // @description 当当前 URL 为指定 URL 时,在控制台打印消息 // @author You // @match *://*/* // @grant none // @license MIT // @downloadURL none // ==/UserScript== (function() { 'use strict'; const targetUrl = 'http://localhost:9201/doc.html#/%E9%A1%B9%E7%9B%AE%E6%80%BB%E8%A7%88/%E7%BB%BF%E8%89%B2%E9%80%9A%E9%81%93/transitionUsingGET'; console.log(window.location.href); function checkUrl() { if (window.location.href === targetUrl) { console.log(window.location.href); console.log('检测到了'); } } checkUrl(); })();