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);