I'm a high school student who likes to just research and learn this kind of thing by myself. Teacher hadn't yet teach these codes i'm interested in. I only know a bit of JS.
I'm trying to use script to add the button "Mark As DONE" besides my homework that shows "NOT DONE" on Google Classoom when the homework list page loads. It ran flewlessly in console. But when i tried to run it by Tampermonkey in order to auto-run once i open that page, it didn't work and got no error displayed in console.
var para = document.getElementsByClassName("EvT0id");
var child = document.getElementsByClassName("MPgfkc EWXgRe ");
for(var i=0;i<para.length;i++){
var x = document.createElement("div");
x.setAttribute("jscontroller","XNjCuf");
x.setAttribute("jsaction","sFeBqf(sFeBqf),ReqGfd(ReqGfd);rcuQ6b:rcuQ6b;wuANJc:rcuQ6b;voP7ud:rcuQ6b;gUFsdf:Yo3LPb");
x.className="oLyi2c bLt3w";
var y = document.createElement("div");
y.className="ZSrdFd V86nAd Vgaus ";
y.setAttribute("role","button");
y.setAttribute("tabindex","0");
y.setAttribute("aria-disabled","false");
y.setAttribute("jsname","sFeBqf");
y.setAttribute("guidedhelpid","submissionManager_markAsDone");
y.innerHTML="Mark As Done";
x.appendChild(y);
var z=document.createElement("iframe");
z.setAttribute("id","tmp_downloadhelper_iframe");
z.style.display = "none";
x.appendChild(z);
//para[i].remove(child[i]);
para[i].appendChild(x);
}
Codes in Tampermonkey:
// ==UserScript==
// @name Enhanced Google Classroom
// @namespace http://tampermonkey.net/
// @version 0.1
// @description try to take over the world!
// @author You
// @match https://classroom.google.com/c/*
// @grant none
// @run-at document-end
// @grant GM_xmlhttpRequest
// @grant unsafeWindow
// @grant GM_addStyle
// @grant GM_getValue
// @grant GM_setValue
// @grant GM_xmlhttpRequest
// @grant GM_registerMenuCommand
// @grant GM_deleteValue
// @grant GM_listValues
// @grant GM_getResourceText
// @grant GM_getResourceURL
// @grant GM_log
// @grant GM_openInTab
// @grant GM_setClipboard
// @grant GM_info
// @grant GM_getMetadata
// ==/UserScript==
(function(){
//var para = document.getElementsByClassName("MPgfkc EWXgRe ");n4xnA MymH0d
var para = document.getElementsByClassName("EvT0id");
var child = document.getElementsByClassName("MPgfkc EWXgRe ");
for(var i=0;i<para.length;i++){
var x = document.createElement("div");
x.setAttribute("jscontroller","XNjCuf");
x.setAttribute("jsaction","sFeBqf(sFeBqf),ReqGfd(ReqGfd);rcuQ6b:rcuQ6b;wuANJc:rcuQ6b;voP7ud:rcuQ6b;gUFsdf:Yo3LPb");
x.className="oLyi2c bLt3w";
var y = document.createElement("div");
y.className="ZSrdFd V86nAd Vgaus ";
y.setAttribute("role","button");
y.setAttribute("tabindex","0");
y.setAttribute("aria-disabled","false");
y.setAttribute("jsname","sFeBqf");
y.setAttribute("guidedhelpid","submissionManager_markAsDone");
y.innerHTML="Mark As Done";
x.appendChild(y);
var z=document.createElement("iframe");
z.setAttribute("id","tmp_downloadhelper_iframe");
z.style.display = "none";
x.appendChild(z);
//para[i].remove(child[i]);
para[i].appendChild(x);
}
})();