您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Adds dark mode, search in tasks and other to MENDO.MK
当前为
- // ==UserScript==
- // @name MENDO.MK Enhancement
- // @namespace -
- // @version 1
- // @description Adds dark mode, search in tasks and other to MENDO.MK
- // @author Plantt
- // @match https://mendo.mk/*
- // @match http://mendo.mk/*
- // @icon https://mendo.mk/img/favicon.ico
- // @grant none
- // @license CC-BY-ND
- // ==/UserScript==
- console.log("%cMENDO.MK Enhancement%c loaded", "color: magenta; text-decoration: underline", "");
- var loadingSuccess = false;
- setTimeout(() => {
- if (loadingSuccess) {
- console.log("Loading %csuccessful", "color: #0f0");
- }
- else {
- console.warn("Loading %cunsuccessful", "color: red");
- }
- }, 1000);
- async function MendoMkEnhancement() {
- function logFinish(taskName) {
- console.log("%cFinished task:%c " + taskName, "color: #0f0", "");
- }
- console.groupCollapsed("Start log");
- loadingSuccess = true;
- var style = document.createElement("style");
- style.innerHTML = `
- html, img, svg, #cboxOverlay {
- filter: invert(1);
- }
- body, img, svg {
- background: white;
- }
- ::-webkit-scrollbar {
- width: initial;
- }
- ::-webkit-scrollbar-track {
- background: #111;
- }
- ::-webkit-scrollbar-thumb {
- background: #222;
- }
- #search {
- font-family: consolas;
- }
- #search, #search-submit {
- border: solid 2px black;
- }
- #search-submit:hover {
- cursor: pointer;
- }
- #search:focus {
- background: #eee;
- }
- #search-submit:hover, #search:hover {
- background: #ddd;
- }
- /*
- * {
- color: white !important;
- background-color: #222 !important;
- }
- h1.pagetitle {
- border-bottom-color: rgb(60, 60, 60) !important;
- }
- a {
- color: darkred !important;
- }
- div.main-navigation *, div.main-navigation {
- background-color: #111 !important;
- }
- */
- `;
- document.head.appendChild(style);
- logFinish("dark mode");
- if (/^http(s)?:\/\/(www\.)?mendo\.mk\/Training\.do/.test(document.URL)) {
- logFinish("training site detected");
- document.querySelectorAll("div.main-content > div:nth-child(3) > div > table > tbody > tr > td:nth-child(2) > a").forEach(e => {
- e.target = "_blank";
- });
- logFinish("make task links open in another window");
- var search = document.createElement("form");
- search.className = "content-search";
- search.action = "#";
- search.innerHTML = `
- <input type=text id=search autocomplete=off>
- <input type=submit id=search-submit value=Search>
- `;
- search.onsubmit = e => {
- e.preventDefault();
- var kw = search.querySelector("#search").value.toLowerCase();
- document.querySelectorAll("body > div.page-container > div.main > div.main-content > div:nth-child(4) > div > table > tbody > tr").forEach(elm => {
- if (!elm.querySelector("td:nth-child(2) > a")) {
- return;
- }
- if (elm.innerText.toLowerCase().includes(kw) || elm.querySelector("td:nth-child(2) > a").href.toLowerCase().includes(kw)) {
- elm.style.display = "";
- }
- else {
- elm.style.display = "none";
- }
- });
- }
- document.querySelector(".main-content").prepend(search);
- logFinish("add task search bar");
- }
- if (document.querySelector("body > div.page-container > div.header > div.header-breadcrumbs > ul > li:last-child > a")) {
- window.name = document.querySelector("body > div.page-container > div.header > div.header-breadcrumbs > ul > li:last-child > a").innerText;
- }
- else if (document.querySelector(".pagetitle")) {
- window.name = document.querySelector(".pagetitle").innerText;
- }
- document.title = window.name + " – МЕНДО";
- logFinish("document title set");
- /*
- if (/^http(s)?:\/\/(www\.)?mendo\.mk\/Task\.do/.test(document.URL)) {
- await fetch("https://entityplantt.github.io/Canvas2d.js/Canvas2d.js").then(arg => arg.text()).then((1, eval));
- console.log(window.Canvas2d);
- async function nameOf(id) {
- var i = document.createElement("iframe");
- i.src = "https://mendo.mk/Task.do?id=" + id;
- i.style.display = "none";
- document.body.append(i);
- await new Promise(res => {
- i.onload = res;
- });
- if (!i.contentDocument.querySelector(".pagetitle")) {
- return null;
- }
- const r = i.contentDocument.querySelector(".pagetitle").innerText;
- i.remove();
- return r;
- }
- window.nameOf = nameOf;
- var canvas = new window.Canvas2d.Scene(), id = parseInt(document.URL.substr(28));
- canvas.background = "#111";
- var grayCircle = await fetch("https://upload.wikimedia.org/wikipedia/commons/thumb/5/55/Small-dark-grey-circle.svg/1024px-Small-dark-grey-circle.svg.png").then(arg => arg.blob());
- grayCircle = await createImageBitmap(grayCircle);
- document.querySelector(".main-content").prepend(canvas.canvas);
- canvas.width = 500;
- var points = new Array, boundLeft = id, boundRight = id, selected = id;
- async function addToPoints(id) {
- points[id] = await nameOf(id);
- var img = new window.Canvas2d.ImageAsset(grayCircle, 50, 50);
- img.posFromCenter = true;
- img.x = 100 * id;
- img.y = canvas.height / 2;
- canvas.add(img);
- var text = new window.Canvas2d.TextAsset(points[id], id * 100, canvas.height / 2, "15px Arial", "white");
- text.align = "center";
- text.baseline = "middle";
- canvas.add(text);
- }
- function extendBound(right) {
- if (right) {
- addToPoints(boundRight);
- boundRight++;
- }
- else {
- addToPoints(boundLeft);
- boundLeft--;
- }
- }
- canvas.context.translate(selected * 100, 0);
- canvas.canvas.onwheel = e => {
- e.preventDefault();
- if (e.deltaY > 0) {
- canvas.context.translate(100, 0);
- selected++;
- }
- else {
- canvas.context.translate(-100, 0);
- selected--;
- }
- while (boundLeft > selected - 5) {
- extendBound(false);
- }
- while (boundRight < selected + 5) {
- extendBound(true);
- }
- canvas.draw();
- };
- canvas.canvas.onwheel({preventDefault: () => {}, deltaY: -1});
- }
- */
- console.groupEnd();
- };
- window.MendoMkEnhancement = MendoMkEnhancement;
- MendoMkEnhancement();