OneClick Tools - Canvas Instructure

Copy/Google with a single click on all instructure.com quizzes/exam questions of your course.

目前为 2024-02-10 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name OneClick Tools - Canvas Instructure
  3. // @namespace https://greasyfork.org/en/users/670188-hacker09?sort=daily_installs
  4. // @version 1
  5. // @description Copy/Google with a single click on all instructure.com quizzes/exam questions of your course.
  6. // @author hacker09
  7. // @match https://*.instructure.com/courses/*/quizzes/*
  8. // @icon https://du11hjcvx0uqb.cloudfront.net/br/dist/images/favicon-e10d657a73.ico
  9. // @run-at document-end
  10. // @grant none
  11. // ==/UserScript==
  12.  
  13. (function() {
  14. 'use strict';
  15. document.querySelectorAll(".text").forEach(el => { //forEach question
  16. el.style.cursor = "pointer"; //Change cursor style to pointer
  17. el.addEventListener('mouseup', function(event) { //When the mouse is clicked
  18. event.preventDefault(); //Prevent the default context menu from being opened
  19. if (event.button === 0) { //If the user single click anywhere on the question/answer
  20. navigator.clipboard.writeText(el.innerText); //Copy the text and question
  21. } else if (event.button === 2) { //If the user right click anywhere on the question/answer
  22. open('https://www.google.com/search?q=' + encodeURIComponent(el.innerText)); //Google the question and answer
  23. } //Finishes the else condition
  24. }); //Finishes the mouseup event listener
  25. }); //Finishes the forEach loop
  26. })();