Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ==UserScript==
- // @name Board Navigation Buttons
- // @namespace GameFAQs
- // @description Restore the board navigation buttons, and add an AMP button
- // @include /http://www\.gamefaqs\.com/boards/[0-9][0-9]*/
- // @grant none
- // @version 1.0
- // @author Frost_shock_FTW
- // ==/UserScript==
- var paginate_button_lists = document.getElementsByClassName( 'paginate user' );
- var topiclist_button = document.createElement( 'li' );
- var topiclist_link = document.createElement( 'a' );
- var topiclist_text = document.createTextNode( 'Topic List' );
- topiclist_link.appendChild( topiclist_text );
- topiclist_link.href = Get_topic_list_url();
- topiclist_button.appendChild( topiclist_link );
- var boardlist_button = document.createElement( 'li' );
- var boardlist_link = document.createElement( 'a' );
- var boardlist_text = document.createTextNode( 'Board List' );
- boardlist_link.appendChild( boardlist_text );
- boardlist_link.href = Get_board_list_url();
- boardlist_button.appendChild( boardlist_link );
- var amp_button = document.createElement( 'li' );
- var amp_link = document.createElement( 'a' );
- var amp_text = document.createTextNode( 'Active Messages Posted' );
- amp_link.appendChild( amp_text );
- amp_link.href = '/boards/myposts.php';
- amp_button.appendChild( amp_link );
- // This script runs on board pages and topic pages.
- // Only insert a Topic List button if we are on a topic page.
- var on_topic_page = document.getElementsByClassName( 'board topics tlist' ).length == 0;
- for( var i = 0; i < paginate_button_lists.length; ++i ) {
- if ( on_topic_page ) {
- paginate_button_lists[i].insertBefore( topiclist_button.cloneNode( true ),
- paginate_button_lists[i].children[1] );
- }
- paginate_button_lists[i].insertBefore( boardlist_button.cloneNode( true ),
- paginate_button_lists[i].children[1] );
- paginate_button_lists[i].insertBefore( amp_button.cloneNode( true ),
- paginate_button_lists[i].children[1] );
- }
- function Get_board_list_url() {
- return window.location.origin + '/boards';
- }
- function Get_topic_list_url() {
- // A GameFAQs topic post link will be in one of two forms:
- // - http://www.gamefaqs.com/boards/BOARDID-BOARD-NAME/TOPICID#POSTNUM
- // - http://www.gamefaqs.com/boards/BOARDID-BOARD-NAME/TOPICID?page=PAGENUM#POSTNUM
- //
- // In both cases, the topic list URL can be found by truncating before the last '/'
- var last_slash_index = window.location.href.lastIndexOf( '/' );
- return window.location.href.slice( 0, last_slash_index );
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement