NOTICE: By continued use of this site you understand and agree to the binding Terms of Service and Privacy Policy.
// ==UserScript== // @name Task expand // @namespace revos // @description Expand task in list // @version 0.29 // @author revos // @include http://wmmail.ru/index.php?cf=uzd-viewtask* // @include http://www.wmmail.ru/index.php?cf=uzd-viewtask* // @license MIT // @run-at document-end // @grant GM_setValue // @grant GM_getValue // ==/UserScript== function expand(id) { var comurl = "a[href='index.php?cf=uzd-commentzd&zdid="+id+"']"; var el = document.getElementById("uzd"+id); if (el.nextSibling.id === "") {el.nextSibling.remove(); el.querySelector(comurl).nextSibling.innerHTML = "Развернуть";} else { function makeRequest (uzd) { return new Promise(function (resolve, reject) { var xhr = new XMLHttpRequest(); xhr.open("GET", "/index.php?cf=uzd-readtask&zdid="+uzd); xhr.onload = function () { if (this.status >= 200 && this.status < 300) { resolve(xhr.response); } else { reject({ status: this.status, statusText: xhr.statusText }); } }; xhr.onerror = function () { reject({ status: this.status, statusText: xhr.statusText }); }; xhr.send(); }); } var tr = document.createElement("tr"); var td = document.createElement("td"); tr.appendChild(td); td.colSpan = 4 makeRequest(id).then(res => {var div = document.createElement("div"); function form() { var el = document.getElementById("uzd"+id).nextSibling; setTimeout(function() {function sendform(number) { return new Promise(function (resolve, reject) {var form = document.querySelectorAll('form')[number]; var data = new FormData(form); var req = new XMLHttpRequest(); req.open("POST", "/index.php", true); req.onload = resolve; req.onerror = reject; req.send(data); }); };sendform(2).then(e => {var lit = document.createElement("div"); lit.innerHTML = e.target.response; el.innerHTML = lit.querySelector("div.top_fon > div > table > tbody > tr > td > table:nth-child(4)").lastChild.firstChild.innerHTML; el.children[0].remove();el.children[1].remove();el.children[0].colSpan = 4;});}, 2000) } var code = "eval((" + form.toString().replace(/id/g, id)+")())"; div.innerHTML = res;var task = div.querySelector("div > div.top_fon > div > table > tbody > tr > td > table:nth-child(4) > tbody > tr:nth-child(1) > td:nth-child(2) > table:nth-child(4) > tbody"); var ttask = task.querySelector('input[onclick="setInterval(function fresh() {location.reload();} , 1000);"]'); if(ttask) {ttask.setAttribute( "onClick", code );}td.appendChild(task); var line = document.createElement("tr"); line.setAttribute("class", "line"); td.firstChild.appendChild(line) var dots = document.createElement("td"); dots.setAttribute("class", "nobdr"); dots.colSpan = 4; line.appendChild(dots);}); var comurl = "a[href='index.php?cf=uzd-commentzd&zdid="+id+"']"; el.parentNode.insertBefore(tr, el.nextSibling);el.querySelector(comurl).nextSibling.innerHTML = "Свернуть";}} function addLink(id) {var link = document.createElement('a'); var el = document.getElementById("uzd"+id); var linkText = document.createTextNode("Развернуть"); link.appendChild(linkText); link.title = "Развернуть"; link.href = "javascript:void(0);"; link.setAttribute("onclick", "expand("+id+")"); var comurl = "a[href='index.php?cf=uzd-commentzd&zdid="+id+"']"; el.querySelector(comurl).parentNode.insertBefore(link, el.querySelector(comurl).nextSibling); link.setAttribute("style", "margin-left: 20px");} function addLink2(id) {var link = document.createElement('a'); var el = document.getElementById("uzd"+id); var linkText = document.createTextNode("Заблокировать домен"); link.appendChild(linkText); link.title = "Заблокировать домен"; link.href = "javascript:void(0);"; link.setAttribute("onclick", "block("+id+")"); el.querySelector("b").parentNode.insertBefore(link, el.querySelector("b").nextSibling); link.setAttribute("style", "margin-left: 20px");} var nodes = document.getElementsByClassName("col2"); var snodes = [...nodes].map(item => item.nextElementSibling); if(nodes[0].previousElementSibling.id === "") {} else {snodes.unshift(nodes[0].previousElementSibling)} var arr = [...nodes]; arr = [...arr].map((e, i) => i < arr.length ? [e, snodes[i]] : [e]).reduce((a, b) => a.concat(b)); if (arr[arr.length-1].id == "") {arr.pop()} for (var i = 0; i < arr.length; i++) { if (arr[i].id !== "") { addLink(arr[i].id.substring(3)); addLink2(arr[i].id.substring(3)); } } var sortlink = document.createElement("a"); var txt = document.createTextNode("Сортировать по домену + отметить цветом"); sortlink.appendChild(txt); sortlink.title = "Сортировать по домену + отметить цветом"; sortlink.href = "javascript:void(0);"; sortlink.setAttribute("onclick", "window.postMessage({sortcolor: 1}, '*');"); arr[0].parentNode.parentNode.previousElementSibling.appendChild(sortlink); function request(url,params,info){ return new Promise(function(resolve,reject){ var xhr=new XMLHttpRequest(); if(info){ xhr.open("POST",url,!0); xhr.setRequestHeader("Content-Type","application/x-www-form-urlencoded"); xhr.onload=function(){!!xhr.responseText.match(/Заметка/g)?resolve():reject()}; xhr.onerror=reject; xhr.send(params)}else{xhr.open("GET",url,!0); xhr.onload=function(){ if(this.status>=200&&this.status<300){ resolve(xhr.response)} else{reject({status:this.status,statusText:xhr.statusText})}}; xhr.onerror=function(){reject({status:this.status,statusText:xhr.statusText})}; xhr.send()}})} function contains(doc,selector,text){var elements=doc.querySelectorAll(selector);return Array.prototype.filter.call(elements,function(element){return RegExp(text).test(element.textContent)})}; function block(id) { var el = document.getElementById("uzd"+id); var domen = el.querySelector("b").textContent.match(/^https?\:\/\/(?:www\.)?([^\/?#]+)(?:[\/?#]|$)/i)[1]; function request(url,params,info){ return new Promise(function(resolve,reject){ var xhr=new XMLHttpRequest(); if(info){ xhr.open("POST",url,!0); xhr.setRequestHeader("Content-Type","application/x-www-form-urlencoded"); xhr.onload=function(){!!xhr.responseText.match(/Заметка/g)?resolve():reject()}; xhr.onerror=reject; xhr.send(params)}else{xhr.open("GET",url,!0); xhr.onload=function(){ if(this.status>=200&&this.status<300){ resolve(xhr.response)} else{reject({status:this.status,statusText:xhr.statusText})}}; xhr.onerror=function(){reject({status:this.status,statusText:xhr.statusText})}; xhr.send()}})} var DMap={0:0,1:1,2:2,3:3,4:4,5:5,6:6,7:7,8:8,9:9,10:10,11:11,12:12,13:13,14:14,15:15,16:16,17:17,18:18,19:19,20:20,21:21,22:22,23:23,24:24,25:25,26:26,27:27,28:28,29:29,30:30,31:31,32:32,33:33,34:34,35:35,36:36,37:37,38:38,39:39,40:40,41:41,42:42,43:43,44:44,45:45,46:46,47:47,48:48,49:49,50:50,51:51,52:52,53:53,54:54,55:55,56:56,57:57,58:58,59:59,60:60,61:61,62:62,63:63,64:64,65:65,66:66,67:67,68:68,69:69,70:70,71:71,72:72,73:73,74:74,75:75,76:76,77:77,78:78,79:79,80:80,81:81,82:82,83:83,84:84,85:85,86:86,87:87,88:88,89:89,90:90,91:91,92:92,93:93,94:94,95:95,96:96,97:97,98:98,99:99,100:100,101:101,102:102,103:103,104:104,105:105,106:106,107:107,108:108,109:109,110:110,111:111,112:112,113:113,114:114,115:115,116:116,117:117,118:118,119:119,120:120,121:121,122:122,123:123,124:124,125:125,126:126,127:127,1027:129,8225:135,1046:198,8222:132,1047:199,1168:165,1048:200,1113:154,1049:201,1045:197,1050:202,1028:170,160:160,1040:192,1051:203,164:164,166:166,167:167,169:169,171:171,172:172,173:173,174:174,1053:205,176:176,177:177,1114:156,181:181,182:182,183:183,8221:148,187:187,1029:189,1056:208,1057:209,1058:210,8364:136,1112:188,1115:158,1059:211,1060:212,1030:178,1061:213,1062:214,1063:215,1116:157,1064:216,1065:217,1031:175,1066:218,1067:219,1068:220,1069:221,1070:222,1032:163,8226:149,1071:223,1072:224,8482:153,1073:225,8240:137,1118:162,1074:226,1110:179,8230:133,1075:227,1033:138,1076:228,1077:229,8211:150,1078:230,1119:159,1079:231,1042:194,1080:232,1034:140,1025:168,1081:233,1082:234,8212:151,1083:235,1169:180,1084:236,1052:204,1085:237,1035:142,1086:238,1087:239,1088:240,1089:241,1090:242,1036:141,1041:193,1091:243,1092:244,8224:134,1093:245,8470:185,1094:246,1054:206,1095:247,1096:248,8249:139,1097:249,1098:250,1044:196,1099:251,1111:191,1055:207,1100:252,1038:161,8220:147,1101:253,8250:155,1102:254,8216:145,1103:255,1043:195,1105:184,1039:143,1026:128,1106:144,8218:130,1107:131,8217:146,1108:186,1109:190} function encode(s){var L=[] for(var i=0;i<s.length;i++){var ord=s.charCodeAt(i) if(!(ord in DMap)) throw "Character "+s.charAt(i)+" isn't supported by win1251!";L.push('%'+DMap[ord].toString(16))} if(typeof InstallTrigger!=='undefined'){return L.join('').toUpperCase().split('%A').join('%0D%0A')}else{return L.join('').toUpperCase().split('%D%A').join('%0D%0A')}} var wmmail="/index.php"; var noteparams=["cf=nb-saddnote&type=0&iname=","&itext="]; function contains(doc,selector,text){var elements=doc.querySelectorAll(selector);return Array.prototype.filter.call(elements,function(element){return RegExp(text).test(element.textContent)})}; var getdomens; async function getnote(){request("index.php?cf=nb-viewallnote") .then(async (a)=>{var parser=new DOMParser(); var doc=parser.parseFromString(a,"text/html"); if(contains(doc,'a',"Domens") == "") {getdomens = ["http://example.com"]}; Array.prototype.forEach.call(contains(doc,'a',"Domens") ,function(a){var url=a.href.split("view").join("del"); request(a.href).then((e) => {var nod = document.createElement('div'); nod.innerHTML = e; function deepText(node){ var A= []; if(node){ node= node.firstChild; while(node!= null){ if(node.nodeType== 3) A[A.length]=node; else A= A.concat(deepText(node)); node= node.nextSibling; } } return A; }; var array = []; var elements = deepText(nod.querySelector("form").querySelectorAll("tr")[4]); for(var i = 0; i < elements.length; i++) { var current = elements[i]; array.push(current.textContent); }; getdomens = (array.filter((e) => e.match((/(^https||^,https)?\:\/\/([^\/?#]+)(?:[\/?#]|$)/i)))).map((e) => e.match(/^https?\:\/\/(?:www\.)?([^\/?#]+)(?:[\/?#]|$)/i)[1]); window.postMessage(domen, "*"); });request(url, "Domens")})}) }; getnote().then((e) => {function waitForElement(){ if(typeof getdomens !== "undefined"){ request(wmmail, noteparams[0]+"Domens"+noteparams[1]+encode(getdomens+","+domen), "rg").catch((e)=>alert("Не удалось добавить домен. Возможно, вы не авторизованы") ) } else{ setTimeout(waitForElement, 250); } }; waitForElement();})}; function addJS_Node (text, s_URL, funcToRun, runOnLoad) { var D = document; var scriptNode = D.createElement ('script'); if (runOnLoad) { scriptNode.addEventListener ("load", runOnLoad, false); } scriptNode.type = "text/javascript"; if (text) scriptNode.textContent = text; if (s_URL) scriptNode.src = s_URL; if (funcToRun) scriptNode.textContent = '(' + funcToRun.toString() + ')()'; var targ = D.getElementsByTagName ('head')[0] || D.body || D.documentElement; targ.appendChild (scriptNode); }; addJS_Node(expand); addJS_Node(block); addJS_Node(color); if(!GM_getValue("domens")) { request("index.php?cf=nb-viewallnote") .then(async (a)=>{var parser=new DOMParser(); var doc=parser.parseFromString(a,"text/html"); Array.prototype.forEach.call(contains(doc,'a',"Domens") ,function(a){request(a.href).then((e) => {var nod = document.createElement('div'); nod.innerHTML = e; function deepText(node){ var A= []; if(node){ node= node.firstChild; while(node!= null){ if(node.nodeType== 3) A[A.length]=node; else A= A.concat(deepText(node)); node= node.nextSibling; } } return A; }; var array = []; var elements = deepText(nod.querySelector("form").querySelectorAll("tr")[4]); for(var i = 0; i < elements.length; i++) { var current = elements[i]; array.push(current.textContent); }; var domens = array.filter((e) => e.match((/(^https||^,https)?\:\/\/([^\/?#]+)(?:[\/?#]|$)/i))); GM_setValue("domens", domens)})})}); } else {var domens = GM_getValue("domens"); var sortcolor = GM_getValue("sortcolor"); if (sortcolor !== 1) { var domencolor = GM_getValue("domencolor"); if (domencolor == undefined) {domencolor = []} else {for (var r = 0; r < arr.length; r++) { if(arr[r].querySelector("b").textContent.match(/^https?\:\/\/(?:www\.)?([^\/?#]+)(?:[\/?#]|$)/i) !== null) { var domen = arr[r].querySelector("b").textContent.match(/^https?\:\/\/(?:www\.)?([^\/?#]+)(?:[\/?#]|$)/i)[1]; for (var i = 0; i < domencolor.length; i++) { if (domencolor[i].domen == domen) {arr[r].className = "";arr[r].firstElementChild.bgColor = domencolor[i].color;} }; }}}; for (var i = 0; i < arr.length; i++) { if (arr[i].id !== "") { addLink3(arr[i].id.substring(3)); } } var newarr = arr.map((e)=> {var object = {}; object.id = e; if (e.querySelector("b").textContent.match(/^https?\:\/\/(?:www\.)?([^\/?#]+)(?:[\/?#]|$)/i)) {object.link = e.querySelector("b").textContent.match(/^https?\:\/\/(?:www\.)?([^\/?#]+)(?:[\/?#]|$)/i)[1];} else { object.link = ""} return object;}) var mySet = new Set(), countObj = {}; for (let obj of newarr) { if (mySet.has(obj.link)) {countObj[obj.link] = countObj[obj.link]+(Math.random() * 0.01)} else { countObj[obj.link] = 1; mySet.add(obj.link); } } newarr = newarr.sort(function(a, b) { return countObj[b.link] - countObj[a.link]; }); var parent = arr[0].parentNode; for (var r = 0; r < arr.length; r++) { parent.insertBefore(newarr[r].id, parent.lastChild); if((r % 2) != 0) {document.getElementById(newarr[r].id.id).children[1].bgColor = "#F5EFDB"; document.getElementById(newarr[r].id.id).children[2].bgColor = "#F5EFDB"; document.getElementById(newarr[r].id.id).children[3].bgColor = "#F5EFDB";} else {document.getElementById(newarr[r].id.id).children[1].bgColor = "white"; document.getElementById(newarr[r].id.id).children[2].bgColor = "white"; document.getElementById(newarr[r].id.id).children[3].bgColor = "white";} }; } for (var r = 0; r < arr.length; r++) { if(arr[r].querySelector("b").textContent.match(/^https?\:\/\/(?:www\.)?([^\/?#]+)(?:[\/?#]|$)/i) !== null) { if(!!domens.includes(arr[r].querySelector("b").textContent.match(/^https?\:\/\/(?:www\.)?([^\/?#]+)(?:[\/?#]|$)/i)[1])) {arr[r].parentNode.removeChild(arr[r]);}}}}; window.addEventListener("message", function (event) { if(event.data.color == undefined && event.data.sortcolor == undefined) { var domens = GM_getValue("domens"); if (domens == undefined) {domens = []; domens.push(event.data)} else {domens.push(event.data)}; domens = [...new Set(domens)]; alert("Заблокировано"); GM_setValue("domens", domens);} else if(event.data.sortcolor == undefined) {var domencolor = GM_getValue("domencolor"); var sortcolor = GM_getValue("sortcolor"); if (sortcolor !== 1) { if (domencolor == undefined) {domencolor = []; domencolor.unshift(event.data)} else {domencolor.unshift(event.data)}; domencolor = domencolor.reduce((unique, o) => { if(!unique.some(obj => obj.domen === o.domen)) { unique.push(o); } return unique; },[]);GM_setValue("domencolor", domencolor); function indexOfAll(array, searchItem) { var i = array.indexOf(searchItem), indexes = []; while (i !== -1) { indexes.push(i); i = array.indexOf(searchItem, ++i); } return indexes; } var obj = {}; obj.domen = event.data.domen; obj.color = event.data.color; //console.log(obj); var indexes = indexOfAll(arr.map(function(e) { if( e.querySelector("b").textContent.match(/^https?\:\/\/(?:www\.)?([^\/?#]+)(?:[\/?#]|$)/i)) {return e.querySelector("b").textContent.match(/^https?\:\/\/(?:www\.)?([^\/?#]+)(?:[\/?#]|$)/i)[1];} }), obj.domen); for (i=0;i<indexes.length;i++) { var index = indexes[i]; arr[index].class = ""; arr[index].firstElementChild.bgColor = obj.color; } } else {}} else {var sortcolor = GM_getValue("sortcolor"); if (sortcolor == 1) {GM_setValue("sortcolor", 0)} else {GM_setValue("sortcolor", 1)}} } ); function addLink3(id) {var link = document.createElement('a'); var el = document.getElementById("uzd"+id); var linkText = document.createTextNode("Выбор цвета для домена"); link.appendChild(linkText); link.title = "Выбор цвета для домена"; link.href = "javascript:void(0);"; link.setAttribute("onclick", "color("+id+")"); el.querySelector("b").parentNode.insertBefore(link, el.querySelector("b").nextSibling); link.setAttribute("style", "margin-left: 20px");} function color(id) { var el = document.getElementById("uzd"+id); function getRandomColor(id) { var letters = '0123456789ABCDEF'; var color = '#'; for (var i = 0; i < 6; i++) { color += letters[Math.floor(Math.random() * 16)]; } var domencolor = {}; domencolor.domen = el.querySelector("b").textContent.match(/^https?\:\/\/(?:www\.)?([^\/?#]+)(?:[\/?#]|$)/i)[1]; domencolor.color = color; window.postMessage(domencolor, "*"); return color; }; el.className = "";el.firstElementChild.bgColor = getRandomColor(id); }