Skip to content

Instantly share code, notes, and snippets.

@mralfarrakhan
Created June 1, 2022 09:24
Show Gist options
  • Select an option

  • Save mralfarrakhan/dec9de4af5e5c855a081fb27e555d200 to your computer and use it in GitHub Desktop.

Select an option

Save mralfarrakhan/dec9de4af5e5c855a081fb27e555d200 to your computer and use it in GitHub Desktop.
get post's op user id
// ==UserScript==
// @name 9Gag OP Finder
// @namespace http://tampermonkey.net/
// @version 0.0.1
// @description 9gag op finder
// @author deadManAlive
// @match https://9gag.com/gag/*
// @icon https://www.google.com/s2/favicons?sz=64&domain=9gag.com
// @grant none
// ==/UserScript==
isAppended = false;
(function(open) {
XMLHttpRequest.prototype.open = function() {
this.addEventListener("readystatechange", function() {
let urlstr = this.responseURL;
let id;
if (urlstr.includes("comment-list.json")) {
try {
id = JSON.parse(this.responseText);
//console.log(this.readyState, id.payload.opUserId);
var op = document.createElement('p');
op.innerHTML = "by ".concat(id.payload.opUserId);
op.id = "op-user-id"
op.style.fontWeight = "bold";
if (isAppended == false){
document.getElementById("jsid-post-".concat(window.location.href.split("/").at(-1))).appendChild(op);
isAppended = true;
}
}
catch (error) {
console.log("9OPF: ", this.readyState, error.message);
}
}
}, false);
open.apply(this, arguments);
};
})(XMLHttpRequest.prototype.open);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment