Makes the new iEMB more tolerable
当前为
// ==UserScript==
// @name iEMB+
// @namespace http://yeoxingyee.ml/
// @version 0.2
// @description Makes the new iEMB more tolerable
// @author YXY
// @match *://iemb.hci.edu.sg/*
// @grant none
// ==/UserScript==
(function(){
'use strict';
var link = document.createElement("link");
link.href = "https://dl.dropboxusercontent.com/s/0highctaaf3h8cz/iemb%2B.css";
link.type = "text/css";
link.rel = "stylesheet";
var script = document.createElement("script");
script.src = "https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.js";
document.getElementsByTagName("head")[0].appendChild(link);
document.getElementsByTagName("head")[0].appendChild(script);
})();
window.onload=function(){
var x = $('.messageboard').length;
var reader = '<button id="reader" onClick="autoread()">Read All</button>';
$(".unread_mess_bg").append(reader);
var scriptinject = document.createElement("script");
scriptinject.innerHTML = ["var i = 0;",
"var x = $('.messageboard').length;",
"function autoread(){",
" console.log('Running checks...');",
" console.log(x + ' messages remaining to read.');",
" if (x=='0'){",
" window.alert('All Messages are already Read!');",
" location.reload();",
" return;",
" }",
" console.log(x);",
" var iframeread;",
" iframeread = document.createElement('iframe');",
" document.body.appendChild(iframeread);",
" iframeread.height = '0';",
" iframeread.src = $('a.messageboard')[i].href;",
" x--;",
" i++;",
" checkread();",
"}",
"function checkread(){",
" if (!x){",
" console.log('Done!');",
" location.reload();",
" }",
"else {",
" console.log('Not done yet! rerunning...');",
" autoread();",
" }",
"}",
].join('\n');
document.getElementsByTagName("head")[0].appendChild(scriptinject);
var iframe = document.createElement("iframe");
};