Making navigating org logs on the website easier.

edited March 2016 in Tech Support
So I got tired of manipulating the URL or going back and forth to view all the logs for a particular org. So my solution? Another tampermonkey script that will add arrows at the top to allow me to navigate back and forth! Since I left all the CSS information empty on the links, it follows the CSS of the website, meaning the arrows are currently blue, and any CSS changes @Tecton or anyone else decide to make will still be followed.

// ==UserScript==
// @name         Navigate Read Logs Easier
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  try to take over the world!
// @author       Patroklos
// @match        http://www.ironrealms.com/game/orglog?*
// @grant        none
// ==/UserScript==
/* jshint -W097 */
'use strict';

var head = document.getElementsByTagName('head')[0];
var link = document.createElement('link');
link.rel = 'stylesheet';
link.type = 'text/css';
link.href = 'https://fonts.googleapis.com/icon?family=Material+Icons';
link.media = 'all';
head.appendChild(link);

var myOrg = getParameterByName("org");
var day = Number(getParameterByName("day"));

var div = document.createElement("div");

var oldLink = document.createElement("a");
oldLink.setAttribute("href", "http://www.ironrealms.com/game/orglog?org=" + myOrg + "&day=" + (day - 1));

var newLink = document.createElement("a");
newLink.setAttribute("href", "http://www.ironrealms.com/game/orglog?org=" + myOrg + "&day=" + (day + 1));

var imgOld = document.createElement("i");
imgOld.setAttribute("class", "material-icons dp48");
if (day <= 0 && myOrg)
{
	imgOld.setAttribute("style", "display:none");
}
imgOld.innerText = "chevron_left";

var imgNew = document.createElement("i");
imgNew.setAttribute("class", "material-icons dp48");
imgNew.setAttribute("style", "float:right");
if (day >= 6 && myOrg)
{
	imgNew.setAttribute("style", "display:none");
}
imgNew.innerText = "chevron_right";

var orgLink = document.getElementsByClassName('active')[0];
var parentDiv = orgLink.parentElement;
oldLink.appendChild(imgOld);
newLink.appendChild(imgNew);

div.appendChild(oldLink);
div.appendChild(newLink);
div.innerHTML = div.innerHTML + "<br />";

parentDiv.appendChild(div);

function getParameterByName(name, url) {
    if (!url) url = window.location.href;
    url = url.toLowerCase(); // This is just to avoid case sensitiveness  
    name = name.replace(/[\[\]]/g, "\\$&").toLowerCase();// This is just to avoid case sensitiveness for query parameter name
    var regex = new RegExp("[?&]" + name + "(=([^&#]*)|&|#|$)"),
        results = regex.exec(url);
    if (!results) return null;
    if (!results[2]) return '';
    return decodeURIComponent(results[2].replace(/\+/g, " "));
}

Hope this helps more people tear their hair out less!

Comments

  • KresslackKresslack Florida, United States
    Haven't tried this on the website yet, but I typically use the IRE extension for Chrome, which works pretty well and lets you navigate quickly between sections. There's one for Firefox as well.


  • Kresslack said:
    Haven't tried this on the website yet, but I typically use the IRE extension for Chrome, which works pretty well and lets you navigate quickly between sections. There's one for Firefox as well.
    Right, this is for those org logs, I think you're thinking of the actual news. Once you actually go to a day for the org logs, you can't hit next or previous day. This allows you to do that without constantly going to the main org page and then changing it from there.
Sign In or Register to comment.