Quizlet.com Export

Adds functionality for copying quizlet lists to the clipboard

目前為 2023-07-11 提交的版本,檢視 最新版本

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name        Quizlet.com Export
// @version     1.0.2
// @author      petracoding
// @namespace   petracoding
// @grant       none
// @license     MIT
// @include     https://quizlet.com/*
// @include     http://quizlet.com/*
// @include     https://www.quizlet.com/*
// @include     http://www.quizlet.com/*
// @description Adds functionality for copying quizlet lists to the clipboard
// ==/UserScript==



// SETTINGS:

const swapTermAndDefinition = false; // true or false
const delimiter = "	"; 		// Use "\n" for a new line. Default: "	"
const delimiterBetweenTerms = "\n";   // Use "\n" for a new line. Default: "\n"







// DO NOT CHANGE ANYTHING BELOW HERE.

start();

function start() {
  const wrapper = document.querySelector(".SetPageHeader");
  if (!wrapper) return;
  
  const el = document.createElement("div");
  
  el.innerHTML = `
    <br/><div class="primary"><a class="action-1 button quizlet-export">Copy to clipboard</a></div>
  `;
  
  wrapper.appendChild(el);
  
  const btn = document.querySelector(".quizlet-export");
  btn.addEventListener("click", () => {
    	copy();
  });
   
}

function copy() {
  const list = document.querySelectorAll(".SetPage-content .SetPageTerms-term");
  let output = "";
  
  [...list].forEach((li) => {
    if (li.querySelector(".count")) {
      li.querySelector(".count").remove();
    }
    
    const lineBreak = " | ";
    
    const term = li.querySelector(".SetPageTerm-wordText .TermText").innerHTML.replaceAll("<br>", lineBreak).trim();
    const definition = li.querySelector(".SetPageTerm-definitionText .TermText").innerHTML.replaceAll("<br>", lineBreak).trim();

    if (swapTermAndDefinition) {
      output += definition + delimiter + term + delimiterBetweenTerms;
    } else {
      output += term + delimiter + definition + delimiterBetweenTerms;
    }
  });
  
  navigator.clipboard.writeText(output);
  alert("Done! All visible terms have been copied to the clipboard, you can now paste them anywhere.\n\nIf you are missing terms make sure to scroll down on your Quizlet list and load all terms before pressing the copy button.");  
}