谷歌在线翻译替换%0A为%20

try to take over the world!

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name         谷歌在线翻译替换%0A为%20
// @namespace    http://tampermonkey.net/
// @version      0.4
// @description  try to take over the world!
// @include      https://translate.google.*/*
// @include      http://fanyi.baidu.com/*
// @author       wxj
// @grant        none
// ==/UserScript==



//window.alert(input);
var preinput="";
window.setInterval(comp,2000);
function comp(){
    var input=window.location.href;
    if(preinput!==input){ //说明改变了输入
        preinput=input;
        rep(input);
    }
    else{
    }
}
//替换函数
function rep(input){
    if(input.indexOf("%0A")!=-1||input.indexOf("Fig.%20")!=-1){ //含有%0A
        var newinput=input.replace(/\%0A/g,"\%20");
        var newinput1=newinput.replace(/Fig\.\%20/g,"Fig\.");
        //var newiput1=newinput.replace(/Fig\.\%20/g,"Fig\.");
        //window.alert(newinput);
        location.href= newinput1;
        //alert("包含");
    }
    else{
        //alert("不包含");
    }
}