Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ==UserScript==
- // @name ASC Add link to last page of long discussions -- February 3, 2017 --
- // @namespace ASCPaginationGoto
- // @description script functions
- // @include https://discussions.apple.com/content?*
- // @include https://discussions.apple.com/community/*/content?*
- // @version 1
- // @grant none
- // ==/UserScript==
- /*
- Add link to last page of long discussions.
- Supported lists:
- https://discussions.apple.com/content?filterID=following~objecttype~objecttype[thread]
- https://discussions.apple.com/community/ipad/ipad_in_business_and_education/content?filterID=contentstatus
- %5Bpublished%5D%7Eobjecttype%7Eobjecttype%5Bthread%5D
- https://discussions.apple.com/community/mac_os/os_x_el_capitan/content?filterID=contentstatus[published]
- ~objecttype~objecttype[thread]
- but not:
- https://discussions.apple.com/community/lounge/full_host_bar
- Why does apple slow down old devices? 66 18035 February 2, 2017 9:15 PM
- in Using iPad by gail from maine by gail from maine
- https://discussions.apple.com/thread/7527129
- https://discussions.apple.com/thread/7527129?start=15&tstart=0
- https://discussions.apple.com/thread/7527129?start=30&tstart=0
- https://discussions.apple.com/thread/7527129?start=45&tstart=0
- https://discussions.apple.com/thread/7527129?start=60&tstart=0
- */
- var debug = 0;
- var replyCounts = new Array();
- var titleCounts = new Array();
- var done = 0;
- var entrySize = 15; // number of discussion listed on web page
- var lastPageStart = 0;
- var constructedLink = "";
- var insertA = "";
- var aDate = new Date();
- console.log ("--> lastReadPage: add fast links " + aDate );
- $("table tr.js-browse-item td.j-td-replies").each(
- function( index )
- {
- replyCounts[index] = $( this ).text();
- }
- );
- if (debug) for ( i = 0;i<replyCounts.length;++i )
- {
- console.log("reply " + i + " is " + replyCounts[i] );
- }
- if (debug) console.log("Find the titles");
- var trSection = $("table tr.js-browse-item td.j-td-title");
- $("a:first", trSection ).each(
- function( index )
- {
- titleCounts[index] = $( this ).text();
- if (debug) console.log("------ " + $( this ).html() + " ------");
- postNumber = $( this ).attr("href").split("/")[2].trim();
- if (debug) console.log("a post number is " + postNumber);
- mathFloorInt = Math.floor(replyCounts[index]/entrySize);
- console.log ("repies = " + replyCounts[index] + " mathFloorInt is " + mathFloorInt );
- if (mathFloorInt) {
- lastPageStart = mathFloorInt * entrySize;
- constructedLink = "https://discussions.apple.com/thread/" +
- postNumber +
- "?start=" +
- lastPageStart +
- "&tstart=0";
- if (debug) console.log("link is " + constructedLink);
- insertA = '<span class="rcUserASCModLastReadPage">' +
- '<a style=" color: SlateBlue; margin-left: 15px; border: 1px dotted black;" ' +
- 'href="' +
- constructedLink +
- '">Last Page</a>' +
- '</span>';
- if (debug) console.log("inserted is " + insertA);
- $( this ).after( insertA );
- }
- } // end of function
- ); // end of .each
- // Seems that javascript [ or someone ]
- // sends the last value from an assignment statement as the return code to the caller.
- done = 0;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement