// ==UserScript== // @name SyndOnlineOnMainPage // @namespace https://github.com/MyRequiem/comfortablePlayingInGW // @description На главной странице персонажа добавляет ссылки на его основной синдикат и союз (если есть), при нажатии на которые выводится онлайн синдиката со ссылками отправки сообщения каждому бойцу. Если персонаж в бою, то ссылка красного цвета. Так же добавляются конвертики для отправки сообщений в разделах "Мои друзья" и "Гости". // @id comfortablePlayingInGW@MyRequiem // @updateURL https://raw.githubusercontent.com/MyRequiem/comfortablePlayingInGW/master/separatedScripts/SyndOnlineOnMainPage/syndOnlineOnMainPage.meta.js // @downloadURL https://raw.githubusercontent.com/MyRequiem/comfortablePlayingInGW/master/separatedScripts/SyndOnlineOnMainPage/syndOnlineOnMainPage.user.js // @include https://*gwars*/me.php* // @include https://*gwars*/me/* // @grant none // @license MIT // @version 2.33-140522 // @author MyRequiem [https://www.gwars.io/info.php?id=2095458] // ==/UserScript== /*global unsafeWindow */ /*jslint browser: true, maxlen: 80, vars: true, plusplus: true, nomen: true, regexp: true */ /*eslint-env browser */ /*eslint no-useless-escape: 'warn', linebreak-style: ['error', 'unix'], quotes: ['error', 'single'], semi: ['error', 'always'], eqeqeq: 'error', curly: 'error' */ /*jscs:disable requireMultipleVarDecl, requireVarDeclFirst */ /*jscs:disable disallowKeywords, disallowDanglingUnderscores */ /*jscs:disable validateIndentation */ (function () { 'use strict'; /** * @class General * @constructor */ var General = function () { /** * @property root * @type {Object} */ this.root = this.getRoot(); /** * @property doc * @type {Object} */ this.doc = this.root.document; /** * @property imgPath * @type {String} */ this.imgPath = 'https://raw.githubusercontent.com/MyRequiem/' + 'comfortablePlayingInGW/master/imgs/'; /** * @property cons * @type {Object} */ this.cons = this.root.console; /** * @property domain * @type {String} */ this.domain = this.doc.domain; }; /** * @lends General.prototype */ General.prototype = { /** * @method getRoot * @return {Object} */ getRoot: function () { var rt = typeof unsafeWindow; return rt !== 'undefined' ? unsafeWindow : window; }, /** * @method $ * @param {String} id * @return {HTMLElement|null} */ $: function (id) { return this.doc.querySelector('#' + id); } }; var general = new General(); /** * @class AjaxQuery * @constructor */ var AjaxQuery = function () { /** * @method init * @param {String} url * @param {Function} onsuccess * @param {Function} onfailure */ this.init = function (url, onsuccess, onfailure) { var xmlHttpRequest = new XMLHttpRequest(); if (!xmlHttpRequest) { general.root.console.log('Error create xmlHttpRequest !!!'); return; } xmlHttpRequest.open('GET', url, true); xmlHttpRequest.send(null); var timeout = general.root.setTimeout(function () { xmlHttpRequest.abort(); }, 10000); xmlHttpRequest.onreadystatechange = function () { if (xmlHttpRequest.readyState === 4) { clearTimeout(timeout); if (xmlHttpRequest.status === 200) { onsuccess(xmlHttpRequest); } else { onfailure(); } } }; }; }; /** * @class SyndOnlineOnMainPage * @constructor */ var SyndOnlineOnMainPage = function () { /** * @property syndUnion * @type {HTMLElement|null} */ this.syndUnion = null; /** * @property syndMain * @type {HTMLElement|null} */ this.syndMain = null; // noinspection FunctionWithInconsistentReturnsJS /** * @method setSms * @return {Boolean} */ this.setSms = function () { var nobrs = general.$('friendsbody').querySelectorAll('nobr'); if (nobrs.length) { var pLink, i; for (i = 0; i < nobrs.length; i++) { pLink = nobrs[i].querySelector('a[href*="/info.php?id="]'); if (pLink) { nobrs[i].innerHTML += '' + ''; } } return false; } }; /** * @method getOnline * @param {Boolean} type */ this.getOnline = function (type) { var target = general.$('friendsbody'); if (!target.querySelector('div')) { target.innerHTML = '
' + (this.syndUnion ? '