Advertisement
Snuggledash

/qa/ on the frame navigation!

Dec 16th, 2019
263
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // ==UserScript==
  2. // @name         /qa/ on the frame navigation!
  3. // @namespace    http://www.4chan.org/
  4. // @version      1023
  5. // @description  Adds /qa/ to 4chan's frames
  6. // @author       (You)
  7. // @match        http://www.4chan.org/frames_navigation
  8. // @match        https://www.4chan.org/frames_navigation
  9. // @match        http://www.4channel.org/frames_navigation
  10. // @match        https://www.4channel.org/frames_navigation
  11. // @grant        none
  12. // ==/UserScript==
  13.  
  14. (function() {
  15.   'use strict';
  16.   let board_title = 'Question & Answer';
  17.   let full_taste = location.hostname.endsWith('4chan.org');
  18.   // roll for perception check!
  19.   let i = document.querySelector('a[href$="/qst/"]');
  20.   if (i === null) {
  21.     // critical failure
  22.     console.error('Could not find insertion point');
  23.     return;
  24.   }
  25.   let qa_link = document.createElement('a');
  26.   qa_link.setAttribute('href', '//boards.' + (full_taste ? '4chan' : '4channel') + '.org/qa/');
  27.   qa_link.setAttribute('target', 'main');
  28.   qa_link.setAttribute('title', board_title);
  29.   qa_link.appendChild(document.createTextNode(board_title));
  30.   let qa_entry = document.createElement('li');
  31.   qa_entry.appendChild(qa_link);
  32.   let insertion_anchor = i.parentNode;
  33.   insertion_anchor.parentNode.insertBefore(qa_entry, insertion_anchor);
  34. })();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement