我目前有以下greasemonkey脚本:
// ==UserScript==
// @name test_script
// @namespace my.example.com
// @include http://example.com/*
// @require http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js
// @version 1
// @grant none
// ==/UserScript==
(function(window, undefined) {
// normalized window
var w;
if (unsafeWindow != "undefined"){
w = unsafeWindow
} else {
w = window;
}
// You can inject almost any javascript library here.
// Just pass the w as the window reference,
// e.g. jquery.min.js embedding:
// (function(a,b){function ci(a) ... a.jQuery=a.$=d})(w);
// do not run in frames
if (w.self != w.top){
return;
}
// additional url check.
// Google Chrome do not treat @match as intended sometimes.
if (/http:\/\/example.com\//.test(w.location.href)){
var link = $('span.link').text();
if (link) {
location.replace(link);
}
}
})(window);
打开example.com
页面后,它会在此处查找 URL 并重定向我。它运行良好,但仅在加载所有图像、样式表等时才会发生重定向。我应该如何解决这个问题?看起来它应该发生在以前。