Last active
March 11, 2023 16:27
-
-
Save lulzsun/f8eff07e74b40126866d83a17d0fb256 to your computer and use it in GitHub Desktop.
Revisions
-
lulzsun revised this gist
Mar 11, 2023 . 2 changed files with 13 additions and 5 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -33,4 +33,9 @@ The script will intercept http POST requests and modify the request body to remo [Alternative solutions](https://github.com/imdonix/canvas-antidetect) tend to patch (prototype polluting) browser events that send the `window.blur` and `window.focus` events. However, this script takes a different approach by patching `window.XMLHttpRequest` to intercept and modify the requests before being sent, which achieves the same result. I feel like this is a cleaner approach and doesn't mess with page functionality relating to blur and focus. Optionally, you can choose to disable the userscript temporarily by opening up the developer tools and type the following: ```js window.cantvas = false; ``` This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -2,7 +2,7 @@ // @name canTvas // @namespace https://gist.github.com/lulzsun/f8eff07e74b40126866d83a17d0fb256 // @downloadURL https://gist.github.com/lulzsun/f8eff07e74b40126866d83a17d0fb256/raw/canTvas.user.js // @version 0.2 // @description Prevents the logging of specific canvas lms quiz events. // @author lulzsun // @match http*://*.instructure.com/* @@ -13,7 +13,8 @@ (function() { 'use strict'; window.cantvas = true; var oldXHROpen = window.XMLHttpRequest.prototype.open; var oldXHRSend = window.XMLHttpRequest.prototype.send; window.XMLHttpRequest.prototype.open = function (method, url) { @@ -29,17 +30,19 @@ // testing for quiz events var regexMatches = new RegExp("*/api/v1/courses/*/quizzes/*/submissions/*/events".replace(/\*/g, "[^ ]*")); if (regexMatches.test(url) && window.cantvas === true) { if (body !== undefined) { var parsedBody = JSON.parse(body); var i = parsedBody["quiz_submission_events"].length; var prevents = 0; while (i--) { var element = parsedBody["quiz_submission_events"][i]; if (element["event_type"] === "page_focused" || element["event_type"] === "page_blurred") { parsedBody["quiz_submission_events"].splice(i, 1); prevents++; } } if (prevents > 0) console.warn(`[canTvas] '${prevents}' event(s) were prevented.`); args[0] = JSON.stringify(parsedBody["quiz_submission_events"]); console.log('on send body:', parsedBody["quiz_submission_events"]); if (parsedBody["quiz_submission_events"].length <= 0) -
lulzsun revised this gist
Mar 6, 2023 . 2 changed files with 2 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -5,7 +5,7 @@ This script prevents Canvas from recieving or logging certain user interactions 1. First you need a userscript manager such as: **Tampermonkey** - [Chrome](https://chrome.google.com/webstore/detail/dhdgffkkebhmkfjojejmpbldmpobfkfo) - [Firefox](https://addons.mozilla.org/en-US/firefox/addon/tampermonkey/) 2. Install the script [Here](https://gist.github.com/lulzsun/f8eff07e74b40126866d83a17d0fb256/raw/canTvas.user.js)! ## Warning Make sure the script loads before attempting any tomfoolery. You can open up the developer console and check for a `console.warn` message that looks like this: This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,7 +1,7 @@ // ==UserScript== // @name canTvas // @namespace https://gist.github.com/lulzsun/f8eff07e74b40126866d83a17d0fb256 // @downloadURL https://gist.github.com/lulzsun/f8eff07e74b40126866d83a17d0fb256/raw/canTvas.user.js // @version 0.1 // @description Prevents the logging of specific canvas lms quiz events. // @author lulzsun -
lulzsun revised this gist
Mar 6, 2023 . No changes.There are no files selected for viewing
-
lulzsun revised this gist
Mar 6, 2023 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -37,7 +37,7 @@ var element = parsedBody["quiz_submission_events"][i]; if (element["event_type"] === "page_focused" || element["event_type"] === "page_blurred") { parsedBody["quiz_submission_events"].splice(i, 1); console.warn(`[canTvas] '${element["event_type"]}' event was prevented.`); } } args[0] = JSON.stringify(parsedBody["quiz_submission_events"]); -
lulzsun revised this gist
Mar 6, 2023 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -37,7 +37,7 @@ var element = parsedBody["quiz_submission_events"][i]; if (element["event_type"] === "page_focused" || element["event_type"] === "page_blurred") { parsedBody["quiz_submission_events"].splice(i, 1); console.warn(`[canTvas] '${element["event_type"]}' event was prevented!`); } } args[0] = JSON.stringify(parsedBody["quiz_submission_events"]); -
lulzsun renamed this gist
Mar 6, 2023 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
lulzsun revised this gist
Mar 6, 2023 . 2 changed files with 2 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,7 +1,7 @@ // ==UserScript== // @name canTvas // @namespace https://gist.github.com/lulzsun/f8eff07e74b40126866d83a17d0fb256 // @downloadURL https://gist.github.com/lulzsun/f8eff07e74b40126866d83a17d0fb256/raw/canTvas.js // @version 0.1 // @description Prevents the logging of specific canvas lms quiz events. // @author lulzsun This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -5,7 +5,7 @@ This script prevents Canvas from recieving or logging certain user interactions 1. First you need a userscript manager such as: **Tampermonkey** - [Chrome](https://chrome.google.com/webstore/detail/dhdgffkkebhmkfjojejmpbldmpobfkfo) - [Firefox](https://addons.mozilla.org/en-US/firefox/addon/tampermonkey/) 2. Install the script [Here](https://gist.github.com/lulzsun/f8eff07e74b40126866d83a17d0fb256/raw/canTvas.js)! ## Warning Make sure the script loads before attempting any tomfoolery. You can open up the developer console and check for a `console.warn` message that looks like this: -
lulzsun revised this gist
Mar 6, 2023 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -5,7 +5,7 @@ This script prevents Canvas from recieving or logging certain user interactions 1. First you need a userscript manager such as: **Tampermonkey** - [Chrome](https://chrome.google.com/webstore/detail/dhdgffkkebhmkfjojejmpbldmpobfkfo) - [Firefox](https://addons.mozilla.org/en-US/firefox/addon/tampermonkey/) 2. Install the script [Here](https://gist.github.com/lulzsun/f8eff07e74b40126866d83a17d0fb256/raw/6efe3f9f788475f10fe075061d2ba2023a18a8a4/canTvas.js)! ## Warning Make sure the script loads before attempting any tomfoolery. You can open up the developer console and check for a `console.warn` message that looks like this: -
lulzsun revised this gist
Mar 6, 2023 . 1 changed file with 4 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,5 +1,5 @@ # canTvas This script prevents Canvas from recieving or logging certain user interactions during quizzes (specifically `page_focused` and `page_blurred`). # Install 1. First you need a userscript manager such as: **Tampermonkey** @@ -22,10 +22,12 @@ Do note that this script could break depending if Canvas instructure changes the var regexMatches = new RegExp("*/api/v1/courses/*/quizzes/*/submissions/*/events".replace(/\*/g, "[^ ]*")); ``` Be cautious and monitor network POST requests to see if any `page_focused` or `page_blurred` events are being sent during a quiz. A request payload could look something like this:  If you do not see any payloads with these events then you are probably safe! ## How it works The script will intercept http POST requests and modify the request body to remove the specified events. -
lulzsun revised this gist
Mar 6, 2023 . 2 changed files with 36 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1 +1,34 @@ # canTvas This script prevents Canvas from recieving certain user interactions (specifically `page_focused` and `page_blurred`). # Install 1. First you need a userscript manager such as: **Tampermonkey** - [Chrome](https://chrome.google.com/webstore/detail/dhdgffkkebhmkfjojejmpbldmpobfkfo) - [Firefox](https://addons.mozilla.org/en-US/firefox/addon/tampermonkey/) 2. Install the script [Here](https://gist.github.com/lulzsun/f8eff07e74b40126866d83a17d0fb256/raw/8cb5ef3199d0c7a466df657cc1c207265a11b3d4/canTvas.js)! ## Warning Make sure the script loads before attempting any tomfoolery. You can open up the developer console and check for a `console.warn` message that looks like this: ``` [canTvas] Userscript loaded successfully. ``` If you don't see this, then it may be because the url doesn't fit `@match`. You will want to change that to fit your needs. Do note that this script could break depending if Canvas instructure changes the api url: ```js // testing for quiz events var regexMatches = new RegExp("*/api/v1/courses/*/quizzes/*/submissions/*/events".replace(/\*/g, "[^ ]*")); ``` Be cautious monitor network POST requests and see if any `page_focused` or `page_blurred` events are being sent. A request payload could look something like this:  ## How it works The script will intercept http POST requests and modify the request body to remove the specified events. [Alternative solutions](https://github.com/imdonix/canvas-antidetect) tend to patch (prototype polluting) browser events that send the `window.blur` and `window.focus` events. However, this script takes a different approach by patching `window.XMLHttpRequest` to intercept and modify the requests before being sent, which achieves the same result. I feel like this is a cleaner approach and doesn't mess with page functionality relating to blur and focus. This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,6 +1,7 @@ // ==UserScript== // @name canTvas // @namespace https://gist.github.com/lulzsun/f8eff07e74b40126866d83a17d0fb256 // @downloadURL https://gist.github.com/lulzsun/f8eff07e74b40126866d83a17d0fb256/raw/8cb5ef3199d0c7a466df657cc1c207265a11b3d4/canTvas.js // @version 0.1 // @description Prevents the logging of specific canvas lms quiz events. // @author lulzsun -
lulzsun created this gist
Mar 6, 2023 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1 @@ # canTvas This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,52 @@ // ==UserScript== // @name canTvas // @namespace https://github.com/lulzsun/canTvas // @version 0.1 // @description Prevents the logging of specific canvas lms quiz events. // @author lulzsun // @match http*://*.instructure.com/* // @match http*://*.canvas.*.edu/* // @icon https://www.google.com/s2/favicons?sz=64&domain=canvaslms.com // @grant none // ==/UserScript== (function() { 'use strict'; var oldXHROpen = window.XMLHttpRequest.prototype.open; var oldXHRSend = window.XMLHttpRequest.prototype.send; window.XMLHttpRequest.prototype.open = function (method, url) { this._url = url; var args = arguments; return oldXHROpen.apply(this, args); }; window.XMLHttpRequest.prototype.send = function (body) { var url = this._url; var args = arguments; // testing for quiz events var regexMatches = new RegExp("*/api/v1/courses/*/quizzes/*/submissions/*/events".replace(/\*/g, "[^ ]*")); if (regexMatches.test(url)) { if (body !== undefined) { var parsedBody = JSON.parse(body); var i = parsedBody["quiz_submission_events"].length; while (i--) { var element = parsedBody["quiz_submission_events"][i]; if (element["event_type"] === "page_focused" || element["event_type"] === "page_blurred") { parsedBody["quiz_submission_events"].splice(i, 1); console.warn(`[canTvas] '${element["event_type"]}' event was prevented.`); } } args[0] = JSON.stringify(parsedBody["quiz_submission_events"]); console.log('on send body:', parsedBody["quiz_submission_events"]); if (parsedBody["quiz_submission_events"].length <= 0) return; } } return oldXHRSend.apply(this, args); }; console.warn(`[canTvas] Userscript loaded successfully.`); })();