OneClick Tools - Canvas Instructure

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

Install this script?
Author's suggested script

You may also like OneClick Tools - McGraw-Hill.

Install this script

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Userscripts to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

// ==UserScript==
// @name         OneClick Tools - Canvas Instructure
// @namespace    https://greasyfork.org/en/users/670188-hacker09?sort=daily_installs
// @version      2
// @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
      var textToCopy = el.cloneNode(true); //Clone the question/answers
      textToCopy.querySelectorAll('.original_question_text, #question_input_1_statusbar, .ic-RichContentEditor, .tox-editor-header, style')?.forEach(editor => editor.remove()); //If existent, select elements to remove their text
      if (event.button === 0) { //If the user single clicks anywhere on the question/answer
        navigator.clipboard.writeText(textToCopy.innerText.replace(/(\r?\n\s*){2,}/g, '\n')); //Copy the text and question
      } else if (event.button === 2) { //If the user right clicks anywhere on the question/answer
        navigator.clipboard.writeText(el.querySelector(".question_text.user_content.enhanced").innerText); //Copy only the question
        open('https://www.google.com/search?q=' + encodeURIComponent(textToCopy.innerText.replace(/(\r?\n\s*){2,}/g, '\n'))); //Google the question and answer
      } //Finishes the else condition
    }); //Finishes the mouseup event listener
  }); //Finishes the forEach loop
})();