// ==UserScript== // @name READTHEDOCS.IO // @namespace http://tampermonkey.net/ // @version 0.3 // @description try to take over the world! // @author You // @match https://geotrellis.readthedocs.io/* // @grant none // @downloadURL none // ==/UserScript== (function() { 'use strict'; const requestUrl = location.protocol === "https:" ? "https://www.sunibas.cn/api" : "http://www.sunibas.cn/api"; window.$jq = jQuery; window.$tran = function (list) { return fetch(requestUrl, { headers: { "Content-Type": "application/json", }, method: "post", body: JSON.stringify({ api: "GoogleTranslate", method: "fetchTran", data: { list: list } }) }).then(_ => _.text()).then(JSON.parse).then(_ => _.data.data); } let tasks = []; window.$tranPElement = function (tar) { let ps = $jq(tar || 'p'); for (let i = 0; i < ps.length; i++) { tasks.push((function (node) { $tran(node.innerText) .then(_ => { $jq(node).replaceWith($jq(`<${node.nodeName} class="ibas_tran">${_}${node.nodeName}>`)); if (tasks.length) { tasks.shift()(); } else { //alert("完成"); } }) .catch(_ => { console.log(_); if (tasks.length) { tasks.shift()(); } else { //alert("完成"); } }) }).bind(null, ps[i])); } if (tasks.length) { tasks.shift()(); } else { alert("完成"); } } window.onload = function() { var content = jQuery('.wy-nav-content'); var parentDiv = content.parent(); parentDiv[0].style.background = "#fff"; content[0].style.float = 'left'; content[0].style.background = 'darkkhaki'; var copyContent = jQuery(`