OneClick Tools - Canvas Instructure

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

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

// ==UserScript==
// @name         OneClick Tools - Canvas Instructure
// @namespace    https://greasyfork.org/en/users/670188-hacker09?sort=daily_installs
// @version      1
// @description  Copy/Google with a single click on all instructure.com quizzes/exam questions of your course.
// @author       hacker09
// @match        https://*.instructure.com/courses/*/quizzes/*
// @icon         https://du11hjcvx0uqb.cloudfront.net/br/dist/images/favicon-e10d657a73.ico
// @run-at       document-end
// @grant        none
// ==/UserScript==

(function() {
  'use strict';
  document.querySelectorAll(".text").forEach(el => { //forEach question
    el.style.cursor = "pointer"; //Change cursor style to pointer
    el.addEventListener('mouseup', function(event) { //When the mouse is clicked
      event.preventDefault(); //Prevent the default context menu from being opened
      if (event.button === 0) { //If the user single click anywhere on the question/answer
        navigator.clipboard.writeText(el.innerText); //Copy the text and question
      } else if (event.button === 2) { //If the user right click anywhere on the question/answer
        open('https://www.google.com/search?q=' + encodeURIComponent(el.innerText)); //Google the question and answer
      } //Finishes the else condition
    }); //Finishes the mouseup event listener
  }); //Finishes the forEach loop
})();