Last active
February 28, 2023 23:12
-
-
Save Tsunder/8bcf52bcc7799d1356befa29a64c2296 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name Combat Log Sector Links | |
// @namespace Pardus | |
// @version 0.1.3 | |
// @description Adds links to the sector map of combat logs | |
// @author Tsunders | |
// @updateURL https://github.com/Tsunder/pardus-script-fun-pack/raw/master/userscripts/pardus_combat_log_map_links.user.js | |
// @downloadURL https://github.com/Tsunder/pardus-script-fun-pack/raw/master/userscripts/pardus_combat_log_map_links.user.js | |
// @match http*://*.pardus.at/overview_combat_log.php* | |
// @match http*://*.pardus.at/combat_details.php* | |
// @grant none | |
// @icon http://www.pardus.at/favicon.ico | |
// 0.1.3 download migration and icon | |
// 0.1.2.2 url fix | |
// 0.1.2.1 url update | |
// 0.1.2 compatilibty with some combat uploaders. link now shows near top of page. | |
// 0.1.1 fluff fix | |
// 0.1 initial publishing | |
// ==/UserScript== | |
// Options, in case of URL changes or language | |
var baseURL = "http://pardusmap.mhwva.net"; //mapper URL, assumes the mapper has the format /Universe/Sector for its sectors. | |
var combatLogFluff = "Confrontation in "; //combat log fluff text before the sector name | |
(function() { | |
'use strict'; | |
var str = document.location.hostname; | |
var universe = str.substring(0, str.indexOf(".")); | |
universe = universe.charAt(0).toUpperCase() + universe.substring(1); | |
if(document.URL.indexOf('pardus.at/overview_combat_log.php') > -1) { | |
var tableData = document.querySelectorAll('td[onclick^=combatDetails]'); | |
for (var i = 0; i < tableData.length; i++) { | |
var _text = tableData[i].innerHTML; | |
if (_text.indexOf(" [") > -1) { | |
var _sector = _text.substring(0,_text.indexOf(" [")); | |
tableData[i].innerHTML = '<a target="_blank" href="' + baseURL + '/' + universe + '/' + _sector + '">' + _text + '</a>'; | |
tableData[i].removeAttribute("onclick"); | |
} | |
} | |
} | |
else if (document.URL.indexOf('pardus.at/combat_details.php') > -1) { | |
var tableData = document.querySelectorAll('tr th'); | |
for (var i = 0; i < tableData.length; i++) { | |
var _text = tableData[i].innerHTML; | |
if (_text.indexOf(" [") > -1) { | |
var _split = _text.split(combatLogFluff); | |
var _sector = _split[1].substring(0, _split[1].indexOf(" [")); | |
var _sectorLink = document.createElement("a"); | |
_sectorLink.appendChild(document.createTextNode(_sector)); | |
_sectorLink.setAttribute("target", "_blank"); | |
_sectorLink.setAttribute("href", baseURL + "/" + universe + "/" + _sector); | |
var _details = document.getElementsByTagName("h2")[0]; | |
_details.append(document.createElement("br")); | |
_details.append(_sectorLink); | |
} | |
} | |
} | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment