// ==UserScript== // @name ASC Pagination Changing: e -- August 24, 2016 // @namespace ASCPaginationGoto // @description script functions // @include https://discussions.apple.com/message/* // @include https://discussions.apple.com/thread/* // @version 1 // @grant none // ==/UserScript== /* Add pagination to the top of Apple Support Communities board web page system introduced in 2016-06 Copyright 2016 rccharles GNU General Public License This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 3 This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. For a copy of the GNU General Public License see . For more information on how to install this script and see: https://discussions.apple.com v0.99 - Beta v0.50 - Alpha - Alpha testing by ccc written by rccharles, August 2016 */ // In case of a serious bug, run in the web console on the page you want to change. // Command+] to indent a highlighted block of text or conversely Command+[ to unindent /* document.getElementById("intro"); document.getElementsByTagName("p"); This example finds the element with id="main", and then finds all

elements inside "main": Example var x = document.getElementById("main"); var y = x.getElementsByTagName("p"); document.getElementsByClassName("intro"); document.querySelectorAll("p.intro"); document.getElementById("demo").innerHTML = text; */ /* if (typeof variable === 'undefined') { // variable is undefined } The typeof operator, unlike the other operators, doesn't throw a ReferenceError exception when used with an undeclared variable. However, do note that typeof null will return "object". We have to be careful to avoid the mistake of initializing a variable to null. To be safe, this is what we could use instead: if (typeof variable === 'undefined' || variable === null) { // variable is undefined or null } */ // What the "from" htlm looks like. //

// // // first // // // Previous // // // // Page // // 3 // of // 3 // // // // // // // What the "to" html looks like. // // ------------------------------------------ // Modify web page downloaded function function cloneGotoChange() { var debug = 0; // alter updateUI /* document.getElementById('tag-id').innerHTML = '
  1. html data
'; */ // Find where to insert the code // We place the code at the beginning of the function var stringed = jspaginate["updateUI"].toString(); var position = stringed.indexOf("{"); position += 1; /* blank lines before and after so to avoid any abuttle problems */ newCode = (` /* very strange, copying data seems to avoid firefox javascript abnormality. What a pain to find. This will be run evertime the user click on a change page icon.*/ var passData = data; var rc = cloneGotoUpate(passData); if (rc) {console.log("--> updateUI returning from cloneGotoUpate rc = " + rc);} `); /* Heavy work of doing the change */ var changedCode = stringed.substr(0, position) + newCode + stringed.substr(position); if ( debug ) console.log ("--> cloneGotoChange: new code:\n" + changedCode); // Inject the changed code // need to use the eval function to make a function assignment instead of a string assignment eval( 'jspaginate["updateUI"] =' + changedCode); if ( debug ) console.log("--> updateUI:\n"+jspaginate["updateUI"].toString() ); /* Template for changing a function. // ............................... newCode = (` `); // Inject the changed code // need to use the eval function to make a function assignment instead of a string assignment eval( 'jspaginate["getData"] =' + newCode); if ( debug ) console.log("--> igetData:\n"+window.jspaginate["init"].toString() ); */ if ( debug ) console.log("--> cloneGotoChange returning. "); } // end of function cloneGotoChange // ------------------------------------------ // Inject the script functions into the web page. function cloneGoto() { var debug = 0; // Create first