Quizlet.com Export

Adds functionality for copying quizlet lists to the clipboard

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

  1. // ==UserScript==
  2. // @name Quizlet.com Export
  3. // @version 1.0.0
  4. // @author petracoding
  5. // @namespace petracoding
  6. // @grant none
  7. // @license MIT
  8. // @include https://quizlet.com/*
  9. // @include http://quizlet.com/*
  10. // @include https://www.quizlet.com/*
  11. // @include http://www.quizlet.com/*
  12. // @description Adds functionality for copying quizlet lists to the clipboard
  13. // ==/UserScript==
  14.  
  15.  
  16.  
  17. // SETTINGS:
  18.  
  19. const delimiter = "\n"; // Use "\n" for a new line. Default: "\n"
  20. const delimiterBetweenWords = "\n\n"; // Use "\n" for a new line. Default: "\n\n"
  21.  
  22.  
  23.  
  24.  
  25.  
  26.  
  27.  
  28. // DO NOT CHANGE ANYTHING BELOW HERE.
  29.  
  30. start();
  31.  
  32. function start() {
  33. const wrapper = document.querySelector(".SetPageHeader");
  34. if (!wrapper) return;
  35. wrapper.innerHTML = wrapper.innerHTML + `
  36. <br/><div class="primary"><a class="action-1 button quizlet-export">Copy to clipboard</a></div>
  37. `;
  38. const btn = document.querySelector(".quizlet-export");
  39. btn.addEventListener("click", () => {
  40. copy();
  41. });
  42. }
  43.  
  44. function copy() {
  45. const list = document.querySelectorAll(".SetPage-content .SetPageTerms-term");
  46. let output = "";
  47. [...list].forEach((li) => {
  48. if (li.querySelector(".count")) {
  49. li.querySelector(".count").remove();
  50. }
  51.  
  52. output += li.querySelector(".SetPageTerm-wordText .TermText").innerHTML.trim() + delimiter + li.querySelector(".SetPageTerm-definitionText .TermText").innerHTML + delimiterBetweenWords;
  53.  
  54. });
  55. navigator.clipboard.writeText(output);
  56. 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.");
  57. }