我是一名喜欢自己研究和学习这类事情的高中生。老师还没教我感兴趣的这些代码。我只知道一点JS。
我尝试使用脚本添加按钮" Mark as DONE"除了我的作业,显示" NOT DONE"加载家庭作业列表页面时在Google Classoom上。它在控制台中完美无瑕地运行。但是当我试图通过Tampermonkey运行它以便在我打开该页面时自动运行它,它没有工作并且没有在控制台中显示错误。
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);
}
&#13;
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);
}
})();
&#13;