Time Left on Tab - Canvas Instructure

Shows the test/quiz/exam time left on the browser tab and also keeps the questions and time fixed on the screen.

  1. // ==UserScript==
  2. // @name Time Left on Tab - Canvas Instructure
  3. // @namespace CanvasTimeHelper
  4. // @version 3
  5. // @description Shows the test/quiz/exam time left on the browser tab and also keeps the questions and time fixed on the screen.
  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. if (document.querySelector("div.time_running") !== null) //If the timer element exists on the page
  16. { //Starts the if condition
  17. setInterval(function() { //Starts the settimeout function
  18. document.title = document.querySelector("div.time_running").innerText;
  19. }, 1000); //Update the tab title to have the current test/quiz/exam left duration time
  20. } //Finishes the if condition
  21.  
  22. document.querySelector("#right-side-wrapper").style.position = 'fixed'; //Make the questions and time elements position fixed on the screen
  23. document.querySelector("#right-side-wrapper").style.right = '0px'; //Make the questions and time elements position fixed on the right side of the screen
  24. document.querySelector("#right-side-wrapper").style.top = '0px'; //Make the questions and time elements position fixed on the top side of the screen
  25. document.querySelector("#questions").style.width = '70%'; //Keep the questions element the same width
  26. document.querySelector("#question_list").style.maxHeight = '430px'; //Fit 18 questions instead of 8
  27.  
  28. })();