// RT Display Next/Prev Links // Daniel Trinkle // Purdue University // 9 July 2010 // // History // 27 August 2010 Added First and Last links, made it easier to change the text in the "buttons" // 16 November 2010 Updated for RT 3.8.8 // 08 April 2011 Added First and Last links in the pagemenu area after Display // 20 April 2011 Updated for RT 3.8.10 // 07 February 2012 Updated for RT 4.0.5 // 08 February 2012 Changed location of txn name tags so top line is visible // // ==UserScript== // @name RT Display Next/Prev Links // @namespace http://www.cs.purdue.edu/homes/trinkle/gm/ // @description Script to jump to next/previous message in a ticket // @include https://help.science.purdue.edu/Ticket/Display.html* // @include https://help.science.purdue.edu/Ticket/History.html* // @version 1.7 // @author Daniel Trinkle // ==/UserScript== // check compatibility var myVersion = " RT 4.0.5 "; var credits = document.getElementById('bpscredits'); if (!credits) { return; } // not RT? if (credits.innerHTML.match(myVersion) == null) { alert("\ Greasemonkey script RT Display Next/Prev Links\n\ is designed to work with " + myVersion + ". It may not\n\ produce desirable results with your version\ "); } // "button" labels var buttonFirst = "First"; var buttonPrev = "Prev"; var buttonNext = "Next"; var buttonLast = "Last"; var hist = document.getElementById('ticket-history'); if (!hist) { return; } // not a ticket display, or no history // on to the real work var allMessages, thisMessage, thisPagemenu; var txn = new Array(); // adjust vertical alignment of "#" in the history via css // only need to modify padding from .75em 0 0 0 to 0 0 .75em 0 // i.e. put padding on the bottom instead of top var rules = document.styleSheets.item(0); rules = rules.cssRules || rules.rules; for (var i = 0; i < rules.length; i++) { if (rules.item(i).selectorText == ".ticket-transaction div.metadata span.type") { rules.item(i).style.padding = "0 0 .75em 0"; }; }; // find all "ticket-transaction message *" divs in the history section allMessages = document.evaluate( "//div[contains(@class,'ticket-transaction message')]", hist, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null); // find txn-xxxxxx names for all messages for (var i = 0; i < allMessages.snapshotLength; i++) { thisMessage = allMessages.snapshotItem(i); link = thisMessage.innerHTML.match(/name=\"txn-[0-9]+\"/); txn[i] = link.toString(); txn[i] = txn[i].replace(/^name=\"/,""); txn[i] = txn[i].replace(/\"$/,""); } // add prev/next links to each message var first = txn[0] ? "href=\"#" + txn[0] + "\"" : ""; var last = txn[i-1] ? "href=\"#" + txn[i-1] + "\"" : ""; thisPagemenu = document.getElementById('page-menu'); thisPagemenu.innerHTML = thisPagemenu.innerHTML.replace(/(Display)<\/a><\/li>/,"$1\n