您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Übersetze ausgewählte englische Worte nach Deutsch mit dict.cc.
// ==UserScript== // @name Ente // @namespace meyerk.com // @match *://*/* // @grant none // @version 0.6 // @author MeyerK // @description Übersetze ausgewählte englische Worte nach Deutsch mit dict.cc. // @noframes // ==/UserScript== class ente { constructor() { this.rightAltKeyIsOn = false; this.isVisible = false; this.frame = document.createElement('iframe'); this.width = 300; } setup() { this.frame.id = 'enteFrame'; this.frame.style.position = 'fixed'; this.frame.style.top = '10px'; this.frame.style.width = this.width+'px'; this.frame.style.padding = '5px'; this.frame.style.height = '100px'; this.frame.style.border = '1px solid blue'; this.frame.style.backgroundColor = 'aliceblue'; this.frame.style.display = 'none'; this.frame.style.borderRadius = '5px'; this.frame.style.zIndex = '2147483646'; document.getElementsByTagName('body')[0].appendChild(this.frame); } handleKeys(ev) { if (this.rightAltKeyIsOn) { if (ev.code == 'KeyU') { let text = window.getSelection().toString(); this.frame.src = "//syn.dict.cc/dcc-gadget.php?s=" + encodeURIComponent(text); this.show(); return false; } } if (ev.code == 'AltRight') { this.rightAltKeyIsOn = (ev.type == 'keydown') ? true : false; } } handleMouse(ev) { if (this.isVisible) { this.hide(); ev.preventDefault(); return false; } } show() { let leftPos = parseInt(window.innerWidth / 2) - parseInt(this.width / 2); this.frame.style.left = leftPos+'px'; this.frame.style.display = 'block'; this.isVisible = true; } hide() { this.frame.style.display = 'none'; this.isVisible = false; } } var en2de = new ente(); en2de.setup(); document.addEventListener('keydown', en2de.handleKeys.bind(en2de)); document.addEventListener('keyup', en2de.handleKeys.bind(en2de)); document.addEventListener('click', en2de.handleMouse.bind(en2de));