// ==UserScript== // @name ASC Goto Test // @namespace https://discussions.apple.com/message // @description This a is test // @include https://discussions.apple.com/message/* // @include https://discussions.apple.com/thread/* // @version 1 // @grant none // ==/UserScript== // In case of a serious bug, run in the javascript console on the page you want to change. //Some debug global variables It must be openned before first debugOut() function // Copy & Past to Javascript console. Press return to run. var aDate = new Date(); var debugMode = ""; var debugPass = ""; var newWindow = ""; var debugWindowName = "debug_ASC_CopyGoto.html" // // Functions to display debug information in another window. // // ------------------------------------------ function startDebug() { if (debugMode == "yes") { // In debug mode, pass debug mode on. debugPass = "debug=yes"; newWindow = window.open("",debugWindowName, "scrollbars=yes,resizable=yes,width=700,height=500"); newWindow.document.writeln( ''); newWindow.document.writeln( ""); newWindow.document.writeln( "
Window " + debugWindowName + "
"); newWindow.document.writeln( "

======================================================" + "===================" + "

"); newWindow.document.writeln( "

The debug information that follows was generated on " + aDate + "

"); } } // ------------------------------------------ function dumpProperties(obj, obj_name) { var i; // Example invocation & print: DumpProperties(document,'document'); if (debugMode == "yes" ) { debugOut('In DumpProperties. obj=' + obj_name); for (i in obj) { try { debugOut(obj_name + "." + i + " = " + obj[i]); } catch(e) { debugOut("Error writing out structure. Was " + e + " for " + i); } } } } // ------------------------------------------ function debugOut(obj) { if (debugMode == "yes" ) { // Put to debug window var newString = ""; var i; for (i=0;i") newString += ">"; else if (obj.substr(i,1) == "&") newString += "&"; else newString += obj.substr(i,1); } newWindow.document.writeln(newString + "
"); } return; } // ------------------------------------------ function countCharacters(n) { if (n.nodeType == 3 && n.parentNode.tagName != "SCRIPT") // Check if n is a Text object { // dumpProperties(n,"n = "); debugOut("n.nodeType = " + n.nodeType + " n.tagName = " + n.tagName); var theParent = n.parentNode; debugOut("theParent.nodeType = " + theParent.nodeType + " theParent.tagName = " + theParent.tagName); debugOut("length of text node = " + n.length + " '" + escape(n.data) + "'"); return n.length; } // Otherwise, n may have children whose characters we need to count var numChars = 0; for (var m = n.firstChild; m != null; m = m.nextSibling) { debugOut("n.nodeType = " + n.nodeType + " n.tagName = " + n.tagName); numChars += countCharacters(m); } return numChars; } // ------------------------------------------ function cloneGoto() { // What the "from" htlm looks like. //
// // // ... clipped ... try { // pageinations are after the original post and after the last post. // They only appear when there is more than one page. var item = document.getElementsByClassName("j-pagination pagination top")[0]; // Copy the element and its child nodes var clone = item.cloneNode(true); // Buid data structure // Create first
  • note var firstLi = document.createElement("lI"); var node = document.createTextNode(" -- "); firstLi.appendChild(node); document.getElementsByClassName("apple-social-actions-toolbar")[0].appendChild(firstLi) // Create second
  • node var secondLi = document.createElement("LI"); // Append pagination // End of with three paginations on page with multipage document secondLi.appendChild(clone); // combine li's //firstLi.appendChild(secondLi); // What the "to" html looks like. // // Append the cloned element to follow [pulldown] document.getElementsByClassName("apple-social-actions-toolbar")[0].appendChild(secondLi); } // end of try // avoid repeated errors at least // first get will fail when there is only one page. catch(err) { // alert(err.message ); // alert(err); } return; } // end of cloneGoto function // ------------------------------------------------------------------------------ debugMode = "yes"; //startDebug(); cloneGoto();