使用油猴(Tampermonkey)插件来添加一个JavaScript脚本。这个脚本将会监听特定的URL,并在用户访问该URL时将其重定向到一个新的URL。
以下是实现这个功能的JavaScript脚本的一个例子:
// ==UserScript== // @name Redirect Script // @namespace http://tampermonkey.net/ // @version 0.1 // @description try to take over the world! // @author You // @match http://192.168.1.254:8000/portal/local/index.html?weburl=http%3A%2F%2Fwww.msftconnecttest.com%2Fredirect // @grant none // ==/UserScript== (function() {'use strict';// 监听页面加载完成事件window.addEventListener('load', function() {// 获取当前URLvar currentURL = window.location.href;// 检查当前URL是否匹配目标URLif (currentURL.indexOf('http://192.168.1.254:8000/portal/local/index.html?weburl=http%3A%2F%2Fwww.msftconnecttest.com%2Fredirect') !== -1) {// 重定向到新的URLwindow.location.href = 'http://192.168.1.254:8000/portal/local/index.html';}}); })();