您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Adds functionality for copying vocabulary lists to the clipboard
当前为
// ==UserScript== // @name Vocabulary.com Export // @version 1.0.0 // @author petracoding // @namespace petracoding // @grant none // @license MIT // @include https://vocabulary.com/* // @include http://vocabulary.com/* // @description Adds functionality for copying vocabulary lists to the clipboard // ==/UserScript== // SETTINGS: const delimiter = "\n"; // Use "\n" for a new line. Default: "\n" const delimiterBetweenWords = "\n\n"; // Use "\n" for a new line. Default: "\n\n" // DO NOT CHANGE ANYTHING BELOW HERE. start(); function start() { const wrapper = document.querySelector(".stats"); if (!wrapper) return; wrapper.innerHTML = wrapper.innerHTML + ` <div class="primary"><a class="action-1 button vocab-export-copy1">Copy to clipboard (Word + Definition)</a></div> <div class="primary"><a class="action-1 button vocab-export-copy2">Copy to clipboard (Example sentence with gaps + Word)</a></div> <div class="vocab-export-done" style="display:none;">Copied!</div> `; const btn1 = document.querySelector(".vocab-export-copy1"); btn1.addEventListener("click", () => { copy(); }); const btn2 = document.querySelector(".vocab-export-copy2"); btn2.addEventListener("click", () => { copy("examples"); }); } function copy(type) { const doneEl = document.querySelector(".vocab-export-done"); const list = document.querySelectorAll(".wordlist .entry"); let output = ""; [...list].forEach((li) => { if (li.querySelector(".count")) { li.querySelector(".count").remove(); } if (type == "examples") { if (li.querySelector(".example")) { [...li.querySelectorAll(".example strong")].forEach(e => e.remove()); if (li.querySelector(".example .source")) { li.querySelector(".example .source").remove(); } output += li.querySelector(".example").innerHTML.replaceAll("\n","___") + delimiter + li.querySelector(".word").innerHTML.trim() + delimiterBetweenWords; } } else { output += li.querySelector(".word").innerHTML.trim() + delimiter + li.querySelector(".definition").innerHTML + delimiterBetweenWords; } }); navigator.clipboard.writeText(output); doneEl.style.display = "block"; setTimeout(function () { doneEl.style.display = "none"; }, 1000); }