Advertisement
Snuggledash

/qa/ on the frontpage!

Nov 3rd, 2018
286
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // ==UserScript==
  2. // @name         /qa/ on the frontpage!
  3. // @namespace    http://www.4chan.org/
  4. // @version      1022
  5. // @description  Adds /qa/ to the frontpage of 4chan
  6. // @author       (You)
  7. // @match        http://4chan.org/
  8. // @match        https://4chan.org/
  9. // @match        http://www.4chan.org/
  10. // @match        https://www.4chan.org/
  11. // @match        http://4channel.org/
  12. // @match        https://4channel.org/
  13. // @match        http://www.4channel.org/
  14. // @match        https://www.4channel.org/
  15. // @grant        none
  16. // ==/UserScript==
  17.  
  18. (function() {
  19.     'use strict';
  20.     try {
  21.         let full_taste = location.hostname.endsWith('4chan.org');
  22.         var board_list;
  23.         if (full_taste) {
  24.             //board_list = document.querySelector('a.boardlink[href$="/pol/"]').parentNode.parentNode;
  25.             // in case some madman actually ever deletes /pol/
  26.             board_list = document.querySelector('a.boardlink[href$="/b/"]').parentNode.parentNode;
  27.         } else {
  28.             // There's no Misc category on 4channel! What do we do?
  29.             // Well, /qa/ is certainly an important board.
  30.             board_list = document.querySelector('a.boardlink[href$="/vip/"]').parentNode.parentNode;
  31.         }
  32.         let qa_link = document.createElement('a');
  33.         // XXX: adapt in case worksafe boards become exclusive to 4channel
  34.         qa_link.setAttribute('href', '//boards.' + (full_taste ? '4chan' : '4channel') + '.org/qa/');
  35.         qa_link.classList.add('boardlink');
  36.         qa_link.appendChild(document.createTextNode('Question & Answer'));
  37.         let qa_entry = document.createElement('li');
  38.         qa_entry.appendChild(qa_link);
  39.         board_list.appendChild(qa_entry);
  40.     // } catch (NullPointerException ex) {
  41.     // Oh, wait. There's no Java in Javascript.
  42.     } catch (err) {
  43.         if (err instanceof TypeError) {
  44.             console.error('Could not found the Misc/Other category on the frontpage! This is kind of bad news.');
  45.             return;
  46.         } else {
  47.             throw(err);
  48.         }
  49.     }
  50. })();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement