您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
A tiny tool making for duolingo exercises better.
当前为
// ==UserScript== // @name Duolingo Search // @namespace http://tampermonkey.net/ // @version 0.1 // @description A tiny tool making for duolingo exercises better. // @author Lepturus // @match *://*.duolingo.com/l* // @match *://*.duolingo.cn/l* // @match *://*.duolingo.com/skill* // @match *://*.duolingo.cn/skill* // @license MIT // @icon https://d35aaqx5ub95lt.cloudfront.net/images/duolingo-touch-icon2.png // @grant none // ==/UserScript== (function () { 'use strict'; function copy(e, isHTML = true) { let obj = document.createElement('input'); document.body.appendChild(obj); obj.value = isHTML ? e.innerText : e; obj.select(); document.execCommand('copy', false); obj.remove(); } function Duolingo() { let kws = document.querySelector('div[dir="ltr"]');let txt=""; if (kws) { let cont = kws.parentNode; let goGoogle = document.createElement("span"); if (kws.querySelector('ruby')){ kws.querySelectorAll('ruby rb div').forEach(function(tp){ txt += tp.innerText; }) } else{ txt = kws.innerText } let goUrl = `https://www.google.com/search?q=${txt}%20site%3Aduolingo.com&ie=utf-8` let goTranslate = `https://translate.google.com/?hl=en&sl=auto&tl=en&text=${txt}` goGoogle.innerHTML = `<a href="${goUrl}" target="_blank">Google</a> <a href="${goTranslate}" target="_blank">Translation</a> <button id ="copyText" style="background: none!important;border: none;padding: 0!important;">Copy it</button>`; if (!cont.textContent.match("Google")) { cont.appendChild(goGoogle); } let cpy = document.getElementById("copyText"); cpy.onclick = function () { copy(txt,false); cpy.innerText = "Copied"; window.setTimeout(function () { cpy.innerText = "Copy it" }, 1500); } } } if (/duolingo/.test(document.URL)) { setInterval(Duolingo, 1500); } })();