Snuggledash icon

/qa/ on the frame navigation!

Snuggledash | PRO | 12/16/19 08:33:22 PM UTC | 0 ⭐ | 703 👁️ | Never ⏰ | []
JavaScript |

1.29 KB

|

None

|

0 👍

/

0 👎

// ==UserScript==
// @name         /qa/ on the frame navigation!
// @namespace    http://www.4chan.org/
// @version      1023
// @description  Adds /qa/ to 4chan's frames
// @author       (You)
// @match        http://www.4chan.org/frames_navigation
// @match        https://www.4chan.org/frames_navigation
// @match        http://www.4channel.org/frames_navigation
// @match        https://www.4channel.org/frames_navigation
// @grant        none
// ==/UserScript==
 
(function() {
  'use strict';
  let board_title = 'Question & Answer';
  let full_taste = location.hostname.endsWith('4chan.org');
  // roll for perception check!
  let i = document.querySelector('a[href$="/qst/"]');
  if (i === null) {
    // critical failure
    console.error('Could not find insertion point');
    return;
  }
  let qa_link = document.createElement('a');
  qa_link.setAttribute('href', '//boards.' + (full_taste ? '4chan' : '4channel') + '.org/qa/');
  qa_link.setAttribute('target', 'main');
  qa_link.setAttribute('title', board_title);
  qa_link.appendChild(document.createTextNode(board_title));
  let qa_entry = document.createElement('li');
  qa_entry.appendChild(qa_link);
  let insertion_anchor = i.parentNode;
  insertion_anchor.parentNode.insertBefore(qa_entry, insertion_anchor);
})();

Comments