![](/img/trans.png)
[英]How do I get the URL for a dropped image using a Chrome userscript?
[英]How do I switch a page to a different domain using a userscript?
我需要使用Greasemonkey替換URL中的特定文本。
例如,如果頁面是:
http://adf.st/?u=https%3A%2F%2Finstagram.com%2Fp%2F4XOVEaD5Ca%2F
然后該腳本將使用以下URL:
http://adfa.cc/?u=https%3A%2F%2Finstagram.com%2Fp%2F4XOVEaD5Ca%2F
注意: adf.st/
之后的其余文本未修復。
這是一個標准問題; 使用下面的模式。
@match
行設置為舊域, newDomain
設置為所需域。
// ==UserScript==
// @name _Redirect from one domain to another
// @match *://adf.st/*
// @run-at document-start
// @grant none
// ==/UserScript==
var newDomain = "adfa.cc";
var newURL = location.protocol + "//"
+ newDomain //-- location.host
+ location.pathname
+ location.search
+ location.hash
;
/*-- replace() puts the good page in the history instead of the
bad page.
*/
location.replace (newURL);
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.