Ke
Advanced Member | Редактировать | Профиль | Сообщение | Цитировать | Сообщить модератору
Код: // ==UserScript== // @name Ignore for Ru-Board // @version 2.2 (25Jan10 17:18:11) // @include http://forum.ru-board.com/* // ==/UserScript== (function() { var IgnName = 'Ignore'; var FrndsName = 'Friends'; var Delim1 = ','; var IgnCnt = -1; var SrchInPth = 'topic.cgi'; var SrchForum = 'forum.cgi'; var FrmsName = 'Forums'; var IgnM = new Array(); var UseNickSearch = true; // false; var LastNickFind = ''; var UseFriends = true; // false; var FriendsColor = '#cfffcf'; var TblText1s = '<table align="center" bgcolor="#999999" border="0" cellpadding="3" cellspacing="1" width="95%">'; var TblText1e = '</table>'; var AddForumS = 'AddForum'; var IsAddForums = true; // false; var FrmLoadListS = ''; var FrmLoaded = ''; var CookDate1 = new Date("1 May 2100 11:00"); function main(IgnS, AddLinks, Reverse, FriendsList) { function HideText(NickName, TrTag) { DivTag = TrTag.getElementsByTagName('div'); if ((DivTag.length > 0) && (DivTag[0].id.indexOf('Ignor') == 0)) { } else { IgnCnt = IgnCnt +1; IgnM[IgnCnt] = TrTag.innerHTML; TrTag.innerHTML = '<div ID=Ignor' +IgnCnt +'><font class=tit> User <b>' +NickName +'</b> ignored. ' +'<a Name=' +IgnCnt +' ID=AIgnor' +IgnCnt +' href=javascript:UnIgn("Ignor' +IgnCnt +'")><u>Show message</u></a></font></div>'; document.getElementById('AIgnor' +IgnCnt).addEventListener("click", function() {UnIgn(this.name)}, false); } } if (IgnS == undefined) {IgnS = ''} var Ign = IgnS.split(Delim1); var TrT = document.getElementsByTagName('tr'); for (var i = 0; i < TrT.length ; i++) { var Btag = TrT[i].getElementsByTagName('b'); if (Btag.length == 0) continue; if (AddLinks == 1) { var TdTag = TrT[i].getElementsByTagName('td'); if (TdTag.length >= 3) { if (TdTag[2].className=="tpc") { var s2 = '' +'<a class="tpc" title="Add or remove ' +"'" +Btag[0].innerHTML +"'" +' from Ignore List" name="' +Btag[0].innerHTML +'"' +' ID=IgnorLink' +i +' href=javascript:AddDelIgn("IgnorLink' +i +'")>Ignore' +'</a> | '; if (UseFriends) { s2 = s2 +'<a class="tpc" title="Add or remove ' +"'" +Btag[0].innerHTML +"'" +' in Friends List" name="' +Btag[0].innerHTML +'"' +' ID=FriendsLink' +i +' href=javascript:AddDelFrnd("FriendsLink' +i +'")>Friend' +'</a> | '; } if (UseNickSearch) { s2 = s2 +'<a class="tpc" title="Find and show messages from ' +"'" +Btag[0].innerHTML +"'" +'" name="' +Btag[0].innerHTML +'"' +' ID=ANickSrch' +i +' href=javascript:NickSrch("' +Btag[0].innerHTML +'")' +'>Find</a>' +' | '; } TdTag[2].innerHTML = '' +s2 +TdTag[2].innerHTML; document.getElementById('IgnorLink' +i).addEventListener("click", function() {AddDelIgn(this.id)}, false); if (UseFriends) { document.getElementById('FriendsLink' +i).addEventListener("click", function() {AddDelFrnd(this.id)}, false); } if (UseNickSearch) { document.getElementById('ANickSrch' +i).addEventListener("click", function() {NickSrch(this.name)}, false); } } } } if (Reverse) { var HrT = TrT[i].getElementsByTagName('hr'); if (HrT.length <= 1) continue; var Find1 = 0; var k1 = 0; for (var j = 0; j < Ign.length; j++) { if (Btag[0].innerHTML != Ign[j]) { Find1 = 1; break; } } if (Find1 == 1) {HideText(Btag[0].innerHTML, TrT[i])} } else { for (var j = 0; j < Ign.length; j++) { if (Btag[0].innerHTML == Ign[j]) { HideText(Ign[j], TrT[i]); break; } } } } if (Reverse) { for (var i = IgnCnt; i >= 0; i--){ var DivTag1 = document.getElementById('Ignor' +i); if (DivTag1 == null) continue; var BTag2 = DivTag1.getElementsByTagName('b'); if (BTag2.length <= 0) continue; for (var j = 0; j < Ign.length; j++) { if (BTag2[0].innerHTML == Ign[j]) {UnIgn(i)} } } } else { for (var i = IgnCnt; i >= 0; i--){ var DivTag1 = document.getElementById('Ignor' +i); if (DivTag1 == null) continue; var BTag2 = DivTag1.getElementsByTagName('b'); if (BTag2.length <= 0) continue; var Find1 = 0; for (var j = 0; j < Ign.length; j++) { if (BTag2[0].innerHTML == Ign[j]) { Find1 = 1; break; } } if (Find1==0) {UnIgn(i)} } } IgnLinkColor(); if (UseFriends) {SetFriendsColor(getCookie(FrndsName));} } if (document.location.pathname.indexOf(SrchInPth) > -1) { main(getCookie(IgnName), 1, false); } function SetFriendsColor(FriendsList) { if ((FriendsList != undefined) && (UseFriends)) { var TrT = document.getElementsByTagName('tr'); var Frnd = FriendsList.split(Delim1); for (var i = 0; i < TrT.length ; i++) { var Btag = TrT[i].getElementsByTagName('b'); if (Btag.length == 0) continue; var TdTag = TrT[i].getElementsByTagName('td'); if (TdTag.length >= 3) { if (TdTag[2].className=="tpc") { if ((FriendsList != undefined) && (UseFriends)) { var Find2 = false; for (var j = 0; j < Frnd.length ; j++) { if (Btag[0].innerHTML == Frnd[j]) { Find2 = true; break; } } if (Find2) { TdTag[1].bgColor = FriendsColor; } else { TdTag[1].bgColor = TdTag[2].bgColor; } } } } } } } function IgnLinkColor(){ var TrT = document.getElementsByTagName('tr'); var Ign2 = getCookie(IgnName); if (Ign2 == undefined) {Ign2 = ''} for (var i = 0; i < TrT.length ; i++) { var ATag = document.getElementById('IgnorLink' +i); if (ATag==null) continue; if (IsTextInStr(ATag.name, Ign2, Delim1)) { ATag.innerHTML = '<font Color=#FF0000>Ignore</font>' } else { ATag.innerHTML = 'Ignore' } } } function UnIgn(IgnCnt){ var PrTag1 = document.getElementById('Ignor' +IgnCnt).parentNode; PrTag1.innerHTML = IgnM[IgnCnt]; IgnLinkColor(); if (UseFriends) {SetFriendsColor(getCookie(FrndsName));} var Tgs1 = PrTag1.getElementsByTagName('a'); for (var i = 0; i < Tgs1.length ; i++) { if (Tgs1[i].id.indexOf('IgnorLink') == 0) { Tgs1[i].addEventListener("click", function() {AddDelIgn(this.id)}, false); break; } } if (UseFriends) { for (var i = 0; i < Tgs1.length ; i++) { if (Tgs1[i].id.indexOf('FriendsLink') == 0) { Tgs1[i].addEventListener("click", function() {AddDelFrnd(this.id)}, false); break; } } } if (UseNickSearch) { for (var i = 0; i < Tgs1.length ; i++) { if (Tgs1[i].id.indexOf('ANickSrch') == 0) { Tgs1[i].addEventListener("click", function() {NickSrch(this.name)}, false); break; } } } } function EditIgn() { var s = getCookie(IgnName); if (s == undefined) {s = ''} if (s==null) {s='';} s = prompt('Ignore editor. Put enimies here. Example: Freak, Troll', s.replace(/^,/g,"")); if(s!=null){ setCookie(IgnName,PrsUsersList(s),{expires:CookDate1}); main(getCookie(IgnName), 0); } }; function EditFrnds() { var s = getCookie(FrndsName); if (s == undefined) {s = ''} if (s==null) {s='';} s = prompt('Ignore editor. Put friends here. Example: Me, Mine, Myself', s.replace(/^,/g,"")); if(s!=null){ setCookie(FrndsName,PrsUsersList(s),{expires:CookDate1}); SetFriendsColor(getCookie(FrndsName)); } }; if (document.location.pathname.indexOf(SrchInPth) > -1) { var Td2T = document.getElementsByTagName('td'); for (var i = 0; i < Td2T.length ; i++) { if ((Td2T[i].className=="dats") && (Td2T[i].align=="right")){ var s1 = ''; if (UseNickSearch) { s1 = '' +'<div Title="Example: ' +"'" +'MyNick, Friend, Etc' +"'" +'. Empty line - reset">Nick search ' +'<input Type=text ID=NickEdit ' +' onkeydown="javascript:if(event.keyCode==13)' +'document.getElementById(' +"'NickBtn'" +').click();"' +'>' +'<button Type=button Name=NickBtn ID=NickBtn OnClick=javascript:NickSrch()>></button></div>' ; } s1 = s1 +'' +' <a ID=IgnEditor title="Ignore List editor" ' +'href=javascript:EditIgn()>Ignore Editor</a> • ' if (UseFriends) { s1 = s1 +'' +'<a ID=IgnFriends title="Friends List editor" ' +'href=javascript:EditFrnds()>Friends Editor</a> • ' } Td2T[i].innerHTML = s1 +Td2T[i].innerHTML; document.getElementById('IgnEditor').addEventListener("click", function() {EditIgn()}, false); if (UseNickSearch) { document.getElementById('NickBtn').addEventListener("click", function() {NickSrch()}, false); } if (UseFriends) { document.getElementById('IgnFriends').addEventListener("click", function() {EditFrnds()}, false); } break; } } } function NickSrch(aNames) { if (aNames == undefined) { var s = PrsUsersList(document.getElementById('NickEdit').value); } else { if (LastNickFind == aNames) { var s = ''; } else { var s = aNames; } } LastNickFind = s; if (s==null) { main(getCookie(IgnName), 0) } else { if (s=='') { main(getCookie(IgnName), 0); } else { main(s, 0, true); } } }; function IsTextInStr(Name, List, Delimetr) { if (List==undefined) {return false} else { var s = List.split(Delimetr); var Find1 = 0; for (var j = s.length -1; j >= 0; j--) { if (s[j] == Name) { s.splice(j, 1); Find1 = 1; break; } } return Find1==1 ? true : false; } } function AddDelIgn(IgnTagName){ var aTag = document.getElementById(IgnTagName); var sName1 = aTag.name; var s1 = getCookie(IgnName); if (s1 == undefined) {s1 = ''} if (IsTextInStr(sName1, s1, Delim1)) { if (confirm('(-) Remove "' +sName1 + '" from Ignore?')) { var sl1 = s1.split(Delim1); var Find1 = 0; for (var j = sl1.length -1; j >= 0; j--) { if (sl1[j] == sName1) { sl1.splice(j, 1); Find1 = 1; } } if (Find1==1) { s1 = sl1.join(Delim1); setCookie(IgnName, s1,{expires:CookDate1}); main(s1, 0); } } } else { if (confirm('(+) Add "' +sName1 + '" to Ignore?')) { s1 = s1 +Delim1 +sName1; setCookie(IgnName, s1,{expires:CookDate1}); main(s1, 0); } } } function AddDelFrnd(FrndTagName){ var aTag = document.getElementById(FrndTagName); var sName1 = aTag.name; var s1 = getCookie(FrndsName); if (s1 == undefined) {s1 = ''} if (IsTextInStr(sName1, s1, Delim1)) { if (confirm('(-) Remove "' +sName1 + '" from Friends?')) { var sl1 = s1.split(Delim1); var Find1 = 0; for (var j = sl1.length -1; j >= 0; j--) { if (sl1[j] == sName1) { sl1.splice(j, 1); Find1 = 1; } } if (Find1==1) { s1 = sl1.join(Delim1); setCookie(FrndsName, s1,{expires:CookDate1}); if (UseFriends) {SetFriendsColor(getCookie(FrndsName));} } } } else { if (confirm('(+) Add "' +sName1 + '" to Friends?')) { s1 = s1 +Delim1 +sName1; setCookie(FrndsName, s1,{expires:CookDate1}); if (UseFriends) {SetFriendsColor(getCookie(FrndsName));} } } } function getCookie(name) { var matches = document.cookie.match(new RegExp( "(?:^|; )" + name.replace(/([\.$?*|{}\(\)\[\]\\\/\+^])/g, '\\$1') + "=([^;]*)" )) return matches ? decodeURIComponent(matches[1]) : undefined } function setCookie(name, value, props) { props = props || {} var exp = props.expires if (typeof exp == "number" && exp) { var d = new Date() d.setTime(d.getTime() + exp*1000) exp = props.expires = d } if(exp && exp.toUTCString) { props.expires = exp.toUTCString() } value = encodeURIComponent(value) var updatedCookie = name + "=" + value for(var propName in props){ updatedCookie += "; " + propName var propValue = props[propName] if(propValue !== true){ updatedCookie += "=" + propValue } } document.cookie = updatedCookie } function deleteCookie(name) {setCookie(name, null, { expires: -1 })} String.prototype.get = function(p){ return (match = this.match(new RegExp("[?|&]?" + p + "=([^&]*)"))) ? match[1] : false;} function insertAfter(parent, node, referenceNode) { parent.insertBefore(node, referenceNode.nextSibling); } function PrsUsersList(aUserNicks) { var s = aUserNicks.replace(/,+/g,","); s = s.replace(/\s+/g," "); s = s.replace(/[, ]$/g,"").replace(/^,/g,""); s = s.replace(/,\s/g,","); return s; } var isPAdding = false; var CurFLoad = -1; var CurForumNbm = window.location.search.get('forum'); if (IsAddForums) { if ( (document.location.pathname.indexOf(SrchForum) > -1) ) { var TrTag3 = document.getElementsByClassName('tit') DTag1 = document.createElement("div"); DTag1.id = 'Div100'; var LoadList2 = getCookie(FrmsName +CurForumNbm); if (LoadList2 == undefined) {LoadList2 = ''} var FrmLoadList = PrsUsersList(LoadList2).split(Delim1); DTag1.innerHTML = '' +'<center>' +'<div id="vote_status1"><br></div>' +'Additional forums: <font id=FForums>' +LoadList2 +'</font>' +' <input id=btnv1 value="Edit"' +' onclick="EdFrmsLst()" type="button" />' +' <font id="vote_status2">Place for server' +"'" +'s answer</font>' +'</center>'; insertAfter(TrTag3[TrTag3.length -1].parentNode.parentNode.parentNode.parentNode, DTag1, TrTag3[TrTag3.length -1].parentNode.parentNode.parentNode); document.getElementById('btnv1').addEventListener("click", function() {EdFrmsLst()}, false); } } function EdFrmsLst() { var s = getCookie(FrmsName +CurForumNbm); if (s == undefined) {s = ''} if (s==null) {s='';} s = prompt('Additional loader editor. Put forum number' +"-" +'s here Example: 13, 72, 75', s.replace(/^,/g,"")); if(s!=null){ FrmLoadListS = PrsUsersList(s); setCookie(FrmsName +CurForumNbm, FrmLoadListS,{expires:CookDate1}); var FrmLoadList = PrsUsersList(FrmLoadListS).split(Delim1); document.getElementById('FForums').innerHTML = s; var FrmLoadedList = PrsUsersList(FrmLoaded).split(Delim1); for (var j = 0; j < FrmLoadedList.length; j++) { if (FrmLoadedList[j] == '') continue; var Find1 = false; for (var i = 0; i < FrmLoadList.length; i++) { if (FrmLoadedList[j] == FrmLoadList[i]) { Find1 = true; break; } } var FrTag1 = document.getElementById(AddForumS +FrmLoadedList[j]); if (FrTag1 == null) continue; if (Find1) { FrTag1.style.display = "inline"; } else { FrTag1.style.display = "none"; } } AddPage1(); } } function AddPage1() { if (CurFLoad != -1) {return false} var statusElem1 = document.getElementById('vote_status1') var statusElem2 = document.getElementById('vote_status2') Find1 = 0; s = getCookie(FrmsName +CurForumNbm); if (s == undefined) {s = ''} var FrmLoadList = PrsUsersList(s).split(Delim1); for (var j = 0; j < FrmLoadList.length; j++) { if (FrmLoadList[j] == '') continue; var tmp3 = document.getElementById(AddForumS +FrmLoadList[j]); if (tmp3 == null) { CurFLoad = FrmLoadList[j]; Find1 = 1; break; } } if (Find1 == 1) { var req = getXmlHttp() req.onreadystatechange = function() { if (req.readyState == 4) { statusElem2.innerHTML = req.statusText +' Forum:' +CurFLoad; if(req.status == 200) { if (document.getElementById(AddForumS +CurFLoad) != null) { CurFLoad = -1; return false; } var temp = document.createElement('div'); temp.innerHTML = req.responseText; var TdTags1 = temp.getElementsByClassName("tit"); var NodeNew1 = document.createElement('div'); NodeNew1.id = AddForumS +CurFLoad; FrmLoaded = FrmLoaded +',' +CurFLoad; if (TdTags1.length >= 2) { var TblTag1 = TdTags1[0].parentNode.parentNode.parentNode; var TblTag2 = TdTags1[1].parentNode.parentNode.parentNode; var TblTag3 = TdTags1[TdTags1.length-1].parentNode.parentNode.parentNode; s1 = '' +'<br>' +TblText1s +TblTag1.innerHTML +TblText1e +TblText1s +TblTag2.innerHTML +TblText1e +TblText1s +TblTag3.innerHTML +TblText1e ; NodeNew1.innerHTML = s1; } else { NodeNew1.innerHTML = '' +'<br>' + 'Error! Forum ' +CurFLoad +' is empty'; } statusElem1.parentNode.insertBefore(NodeNew1, statusElem1); var tmp3 = document.getElementById(AddForumS +CurFLoad); CurFLoad = -1; AddPage1(); } else { var NodeNew1 = document.createElement('div'); NodeNew1.id = AddForumS +CurFLoad; NodeNew1.innerHTML = '' +'<br>' + 'Error! No response from Forum ' +CurFLoad +'.'; statusElem1.parentNode.insertBefore(NodeNew1, statusElem1); var tmp3 = document.getElementById(AddForumS +CurFLoad); CurFLoad = -1; AddPage1(); } } } req.open('GET', '/forum.cgi?forum=' +CurFLoad, true); req.send(null); statusElem2.innerHTML = 'Loading' +' forum:' +CurFLoad; } else { statusElem2.innerHTML = 'All pages loaded.'; } } function getXmlHttp(){ var xmlhttp; try { xmlhttp = new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { try { xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); } catch (E) { xmlhttp = false; } } if (!xmlhttp && typeof XMLHttpRequest!='undefined') { xmlhttp = new XMLHttpRequest(); xmlhttp.overrideMimeType('text/html'); } return xmlhttp; } if (IsAddForums) {AddPage1()}; })(); | | Всего записей: 970 | Зарегистр. 29-11-2004 | Отправлено: 17:53 25-01-2010 | Исправлено: Ke, 01:43 03-02-2010 |
|