我只是試圖讓這個腳本:Greasemonkey腳本修改URL不起作用?
// ==UserScript==
// @name Link Bypasser Script
// @include *http://onion.com/*
// @run-at document-start
// ==/UserScript==
var oldUrl = window.location;
var newURL = "http://localhost:8887/processor.php?link=" + oldUrl;
window.location.replace (newURL);
我「inlcude」多個URL,但我不認爲這是相關的展示,反正,這個劇本我覺得會變成,例如,http://onion.com/4GUTDTA
到http://localhost:8887/processor.php?link=http://onion.com/4GUTDTA
,但沒有任何反應:
這個我嘗試過:
var oldUrlPath = window.location.path;
有:
+ "http://localhost:8887/processor.php?link=" + oldUrlPath
沒有哪個然而修改它,但它只是增加了路徑,這是有意義的之前的鏈接,因爲我用window.location.path
。我也試過用
var oldUrl = window.location.href;
哪沒什麼。
我不明白這到底是怎麼正確的。它將搜索和哈希部分兩次添加到新的URL。 – trincot
@trincot是否必須在調用window.location.replace之前調用decodeURIComponent()?此外,我刪除了額外的搜索和散列部分 – koolhuman