使用Greasemonkey(或类似的用户脚本引擎)更快地重定向? [英] Redirect faster with Greasemonkey (or similar userscript engine)?

查看:104
本文介绍了使用Greasemonkey(或类似的用户脚本引擎)更快地重定向?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Greasemonkey将某些网址重定向到另一个网址,但我想在重定向网址加载之前重定向。

I'm using Greasemonkey to redirect certain URLs to another but I would like to redirect before the URL to be redirect loads.

目前我正在使用这个简单的脚本:

Currently I'm using this simple script:

//==UserScript==
// @name Redirect Google
// @description Redirect Google to Yahoo!
// @include http://*.google.com/*
//==/UserScript==
window.location.replace("http://www.yahoo.com")

在上面,Google会出现一秒钟,然后重定向到Google。我想马上去雅虎。是可能的,怎么样?

In the above, Google appears for a second and then redirected to Google. I want to go yahoo immediately. Is it possible, and how?

推荐答案

你可以用 Doc 中的rel =nofollow> @ run-at document-start

EG:

You can use @run-at document-start in the metadata blockDoc.
EG:

//==UserScript==
// @name Redirect Google
// @description Redirect Google to Yahoo!
// @include http://*.google.com/*
// @run-at document-start
//==/UserScript==
window.location.replace ("http://www.yahoo.com")



脚本将在任何文档开始加载之前运行,因此在任何脚本运行或图像加载之前运行。


The script will run before any document begins loading, thus before any scripts run or images load.

这篇关于使用Greasemonkey(或类似的用户脚本引擎)更快地重定向?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆