Created
September 27, 2020 05:55
-
-
Save itsmeow/d9c9f6956b8514ef84d9866664e029e1 to your computer and use it in GitHub Desktop.
Fix Classroom Links
This file contains 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 characters
// ==UserScript== | |
// @name Fix Classroom Links | |
// @namespace https://itsmeow.dev/ | |
// @version 0.1 | |
// @description Switches classroom links to u/6/ | |
// @author itsmeow | |
// @match https://mail.google.com/mail/u/6/ | |
// @require https://ajax.googleapis.com/ajax/libs/jquery/2.1.0/jquery.min.js | |
// @require https://gist.github.com/raw/2625891/waitForKeyElements.js | |
// @grant none | |
// ==/UserScript== | |
(function() { | |
'use strict'; | |
const userid = "6" | |
function fix(e) { | |
if(e && e.href && !e.href.match(/^https:\/\/classroom\.google\.com\/u\//g)) { | |
let href = e.href; | |
let href2 = href.substring(0, "https://classroom.google.com/".length) + "u/" + userid + "/" + href.substring("https://classroom.google.com/".length); | |
let safe = e.dataset.saferedirecturl; | |
let safe2 = safe.substring(0, "https://www.google.com/url?q=https://classroom.google.com/".length) + "u/" + userid + "/" + safe.substring("https://www.google.com/url?q=https://classroom.google.com/".length); | |
e.href = href2; | |
e.dataset.saferedirecturl = safe2; | |
} | |
} | |
waitForKeyElements ("a[href^=\"https://classroom.google.com/c/\"]", check => { | |
fix(check[0]); | |
var observer = new MutationObserver(m => fix(check[0])); | |
observer.observe(check[0], {characterData: true, childList: true, attributes: true, subtree: true}); | |
}); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment