Skip to content

Instantly share code, notes, and snippets.

@haylinmoore
Created February 20, 2024 17:01
Show Gist options
  • Save haylinmoore/2becce0c28af5791518fd75ab4da673f to your computer and use it in GitHub Desktop.
Save haylinmoore/2becce0c28af5791518fd75ab4da673f to your computer and use it in GitHub Desktop.
// ==UserScript==
// @name Campuswire-oops
// @version 0.1
// @author Hampton Moore
// @match https://campuswire.com/*
// @grant none
// @run-at document-body
// ==/UserScript==
window.xhrold = XMLHttpRequest;
class XHRNew extends window.xhrold {
constructor(...methods){
super(...methods);
console.log("xhr created");
}
addEventListener(...args){
super.addEventListener(...args)
}
send(...args){
console.log(this)
super.addEventListener("load", reqListener);
super.send(...args)
}
}
XMLHttpRequest = XHRNew;
function reqListener() {
if (!this.responseURL.includes("/messages")){
return;
}
let data = JSON.parse(this.responseText)
let poster = data[0]["author"]
if (userBox != null) {
userBox.innerHTML = `Viewing ${poster["firstName"]} ${poster["lastName"]}`
}
}
var userBox = null;
window.addEventListener("load", (event) => {
var div = document.createElement("div");
div.id="userBox"
div.style.color = "white";
div.style.fontSize = "16px";
div.style.background = "#0084FF";
div.style.position = "absolute"
div.style.zIndex = "100";
div.style.right = "4px";
div.style.bottom = "4px";
div.style.textAlign = "right";
div.style.borderRadius = "15px";
div.style.padding = "8px";
div.innerHTML = "";
document.body.appendChild(div);
userBox = document.getElementById('userBox')
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment