google translate utils

auto remove line break for google translate(replaced with space)

目前為 2018-11-19 提交的版本,檢視 最新版本

// ==UserScript==
// @name         google translate utils
// @name:zh-CN   google翻译实用工具
// @namespace    https://github.com/tabedit/tamperMonkey
// @version      0.2.1
// @description  auto remove line break for google translate(replaced with space)
// @description:zh-CN 自动移除google翻译原文中的换行符(替换为空格)
// @author       tabedit
// @include     http*://translate.google.*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    // loop function
    function checkloop(){
        var pattern = /https:\/\/translate\.google\..*\//
        var headUrl=pattern.exec(location.href)[0]
        var tailUrl=location.href.slice(headUrl.length);
        var tailUrlDecode = decodeURIComponent(tailUrl);
        if ( tailUrlDecode.lastIndexOf('\n') >= 0 ){
            // 去除连字符
            tailUrlDecode = tailUrlDecode.replace(/-[\r\n]/g,'');
            // 移除行尾空格
            tailUrlDecode = tailUrlDecode.replace(/[\r\n]/g,' ');
            tailUrl = encodeURIComponent(tailUrlDecode);
            location.href = headUrl + tailUrl;
        }
    }

    var answer=confirm("是否启用原文自动替换换行符");
    if (answer){
        setInterval(checkloop, 100);
    }
})();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址