0

I would like to be able to easily see GitHub PRs that I reviewed and that are still open. The GitHub browser interface doesn't make this easy, but the data are readily available as a query. I thought it would be easy to add a button.

The function commands work fine when copy-pasted into the console after the page is loaded. Under Violentmonkey, the function seems to be triggered at the right time during loading but nothing happens. What am I doing wrong? Thanks for all tips.

// ==UserScript==
// @name        GitHub Pull: All review requests button
// @namespace   Violentmonkey Scripts
// @match       https://github.com/pulls
// @grant       MIT
// @version     1.0
// @author      Reece Hart <reecehart@gmail.com>
// @description Add button to show previously reviewed pull requests
// @require     https://code.jquery.com/jquery-3.6.1.slim.min.js
// @require     https://gist.github.com/raw/2625891/waitForKeyElements.js
// ==/UserScript==

function updateNavBar () {
  console.log("Adding All review requests button")
  a = $("a[title='Pull Requests requesting your review']")
  b = a.cloneNode(true)
  b.setAttribute("title", "All review requests")
  b.innerHTML = "All review requests"
  b.setAttribute("data-selected-links", b.getAttribute("data-selected-links").replace("review-requested", "reviewed-by"))
  b.setAttribute("href", b.getAttribute("href").replace("review-requested", "reviewed-by"))
  a.after(b)
}

waitForKeyElements ("a[title='Pull Requests requesting your review']", updateNavBar);
TheMaster
  • 45,448
  • 6
  • 62
  • 85
Reece
  • 7,616
  • 4
  • 30
  • 46
  • 4
    `TypeError: a.cloneNode is not a function` in the console. `.cloneNode()` is the browser API, not jQuery. Same with `innerHTML`, `.setAtribute()`, and `.getAttribute()`. Only `.after()` is jQuery. Either use jQuery and change over to the appropriate methods, or just don't use it and change to `document.querySelector` and replace `.after()`. – VLAZ Oct 28 '22 at 05:09
  • 2
    + make sure you're using the latest Violentmonkey, which fixed a bug about showing errors in console. – wOxxOm Oct 28 '22 at 07:34

0 Answers0