NOTICE: By continued use of this site you understand and agree to the binding Terms of Service and Privacy Policy.
// ==UserScript== // @name MafiEra PlayerInfo Tool // @version 5 // @namespace http://www.fireblend.com/ // @updateURL https://openuserjs.org/meta/Fireblend/MafiEra_PlayerInfo_Tool.meta.js // @downloadURL https://openuserjs.org/src/scripts/Fireblend/MafiEra_PlayerInfo_Tool.user.js // @license MIT // @icon https://media.discordapp.net/attachments/165286383257255936/429860317649174529/imageedit__4571108207.png // @homepageURL http://www.fireblend.com/ // @author Sergio Morales // @description Add a player info reminder close to the post reply button! // @include http*://www.resetera.com/threads/* // @include http*://www.resetera.com/threads/*/* // @require https://code.jquery.com/ui/1.12.1/jquery-ui.js // @resource customCSS https://code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css // @run-at document-idle // @grant GM_addStyle // @grant GM_getResourceText // ==/UserScript== (function () { 'use strict'; function checkMafiaGame() { var url = window.location.href; var request = new XMLHttpRequest(); request.open('GET', url.replace(url.split("/threads/")[1].split("/")[1], ""), true); request.responseType = "document"; request.onreadystatechange = function () { if (request.readyState === 4) { var text = request.response.getElementsByClassName("bbHighlight")[0].textContent; if (text !== undefined && text.includes("!player_list")) { text = text.replace(/!player_list/g, ""); text = textTransform(text); addHoverText(text); } } }; request.send(); } function textTransform(text) { var list = []; var lines = text.split(/\r?\n/); var regexp = /\[(.+)\] (.+) - (.+)/; lines.forEach(function (element) { var match = regexp.exec(element); if (match != undefined) { list.push(match[2] + ": " + match[1]); } }) list.sort(function (a, b) { return a.toLowerCase().localeCompare(b.toLowerCase()); }); return list.join("\n"); } function addHoverText(text) { var locations = document.getElementsByClassName("formButtonGroup-extra") Array.prototype.forEach.call(locations, function (location) { var a = document.createElement('a'); a.setAttribute('id', 'pronounTooltip'); a.setAttribute('style', 'cursor:pointer; font-size:15px;'); a.setAttribute('title', text); a.appendChild(document.createTextNode("Player Info (Hover)")); $("#pronounTooltip").tooltip(); location.appendChild(a); }); } checkMafiaGame() })();