shura1973
Silver Member | Редактировать | Профиль | Сообщение | Цитировать | Сообщить модератору // ==UserScript== // @name RU_Board WhosOnline // @author Yurchik09 // @include http://forum.ru-board.com/* // @icon https://addons.cdn.mozilla.net/img/uploads/addon_icons/473/473152-64.png // @description Подсвечивает пользователей, которые в данный момент находятся на форуме RU-Board. // @grant none // @version 1.6 // @run-at document-end // ==/UserScript== this.whosonline = ({ autoHighlight: false, url: '/whosonline.cgi', load: function () { if (this.xmlHttp) return; try { this.xmlHttp = new XMLHttpRequest() if (this.xmlHttp.overrideMimeType && this.method == 'POST') this.xmlHttp.overrideMimeType('text/html'); } catch (e) { var msv = ["Msxml2.XMLHTTP.7.0", "Msxml2.XMLHTTP.6.0", "Msxml2.XMLHTTP.5.0", "Msxml2.XMLHTTP.4.0", "MSXML2.XMLHTTP.3.0", "MSXML2.XMLHTTP", "Microsoft.XMLHTTP"] for (var j = 0; j <= msv.length; j++) { try { this.xmlHttp = new ActiveXObject(msv[j]) break } catch (e) {} } if (!this.xmlHttp) return false } var self = this this.xmlHttp.onreadystatechange = function () { if (self.xmlHttp.readyState == 4) { self.processResponse(self.xmlHttp.responseText) self.xmlHttp = null; } } this.xmlHttp.open("GET", this.url + '?timestamp=' + Math.floor(new Date().valueOf() / 60000), true); this.xmlHttp.send(null); }, processResponse: function (text) { var users = {}; text.replace(/<a href="profile\.cgi\?action=show&member=.*?">(.*?)<\/a>/g, function (a, b) { users[b] = true; }); this.users = users; this.autoHighlight && this.highlightUsers(); }, highlightUsers: function () { if (!this.users) { this.autoHighlight = true; if (!this.xmlHttp) { this.load(); } return; } try { var elements = document.getElementsByTagName('B'); for (var i = 0; i < elements.length; i++) { if (elements[i].parentNode.className == 'm' && this.users[elements[i].innerHTML]) { var onlinestatus = document.createElement('div'); onlinestatus.style.display = 'inline-block'; onlinestatus.style.width = '9px'; onlinestatus.style.height = '9px'; onlinestatus.style.background = '#32CD32'; onlinestatus.style.borderRadius = '9px'; onlinestatus.style.borderTop = '1px solid #006400'; onlinestatus.style.borderLeft = '1px solid #006400'; onlinestatus.style.borderRight = '1px solid #006400'; onlinestatus.style.borderBottom = '1px solid #006400'; onlinestatus.style.marginLeft = '4px'; onlinestatus.title = 'Онлайн'; elements[i].parentNode.insertBefore(onlinestatus, elements[i].nextSibling); } } } catch (e) { alert(e.message); } }, run: function () { return this; } }).run(); whosonline && (whosonline.load(), window.onload = function () { whosonline.highlightUsers(); }); | Всего записей: 4946 | Зарегистр. 14-10-2007 | Отправлено: 11:38 28-12-2015 | Исправлено: shura1973, 11:40 28-12-2015 |
|