Qidian.com Translate Enabler

Enable Google Translate on qidian.com

< 脚本Qidian.com Translate Enabler的反馈

评价:一般 - 脚本能用,但还有一些问题

§
发表于:2024-08-23

"do note you have to press the translate button" But there is a problem - i can't press the translate button because I do not see any button. (maybe it just doesn't work for me). I made script below with using chatgpt, just enabled the right click to have possibility to press THE TRANSLATION BUTTON.

// ==UserScript==
// @name Qidian.com Translator and Right Click Enabler
// @namespace http://tampermonkey.net/
// @version 1.0
// @description Enable Google Translate and right-click context menu on qidian.com
// @author Your Name
// @match *://*.qidian.com/*
// @grant none
// ==/UserScript==

(function() {
'use strict';


function enableFeatures() {

let htmlTag = document.documentElement;
htmlTag.setAttribute("translate", "yes");
htmlTag.classList.remove("notranslate");


document.addEventListener('contextmenu', function(e) {
e.stopImmediatePropagation();
}, true);
document.querySelectorAll('*').forEach(function(element) {
element.addEventListener('contextmenu', function(e) {
e.stopImmediatePropagation();
}, true);
});
}


window.addEventListener('load', enableFeatures);


const observer = new MutationObserver(enableFeatures);
observer.observe(document.body, { childList: true, subtree: true });
})();

发表回复

登录以发表回复。