jcunews

ReaddGitHubReleasesTab.user.js

Nov 29th, 2020 (edited)
542
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // ==UserScript==
  2. // @name         Readd GitHub Releases Tab
  3. // @namespace    https://greasyfork.org/en/users/85671-jcunews
  4. // @version      1.0.1
  5. // @license      AGPLv3
  6. // @author       jcunews
  7. // @description  https://www.reddit.com/r/userscripts/comments/k39flt/request_releases_tab_for_github_userscript/
  8. // @match        https://github.com/*/*
  9. // @grant        none
  10. // ==/UserScript==
  11.  
  12. (() => {
  13.   document.querySelectorAll('a[href*="/releases"]').forEach((el, ctr, svg, nav, tab) => {
  14.     if (ctr = el.querySelector(".Counter")) {
  15.       svg = el.parentNode.parentNode.querySelector("svg");
  16.       nav = document.querySelector(".UnderlineNav-body");
  17.       (tab = document.createElement("LI")).className = "d-flex";
  18.       tab.innerHTML = `
  19. <a class="js-selected-navigation-item UnderlineNav-item hx_underlinenav-item no-wrap js-responsive-underlinenav-item" data-tab-item="releases-tab" data-hotkey="g r">
  20.   ${svg ? svg.outerHTML : ""}
  21.   <span data-content="Releases">Releases</span>
  22.   <span title="${ctr.title}" class="Counter ">${ctr.textContent}</span>
  23. </a>`;
  24.       tab.firstElementChild.href = el.href;
  25.       nav.insertBefore(tab, nav.children[1]);
  26.     }
  27.   });
  28. })();
  29.  
RAW Paste Data