Github Commit Diff

Adds button to show diff (or patch) file for commit

< Feedback on Github Commit Diff

Review: Bad - script does not work

§
Posted: 15/07/2023

Doesn't seem to work in the new GitHub UI. Here's how the buttons "Splut/Unified" look like in the new UI:

A stacktrace appears in the console:

 Uncaught (in promise) TypeError: b is null
    addButton moz-extension://047311dd-ae1f-4370-b50a-d5d819e266b9/userscripts/Github-Commit-Diff.user.js?id=ef4782ed-174b-4e3c-acd5-007e4c3685bd:58
    window["__f__lk4jg1u3.dgq"]/</< moz-extension://047311dd-ae1f-4370-b50a-d5d819e266b9/userscripts/Github-Commit-Diff.user.js?id=ef4782ed-174b-4e3c-acd5-007e4c3685bd:127
    window["__f__lk4jg1u3.dgq"]/< moz-extension://047311dd-ae1f-4370-b50a-d5d819e266b9/userscripts/Github-Commit-Diff.user.js?id=ef4782ed-174b-4e3c-acd5-007e4c3685bd:132
    St https://github.com/rybak/github-pr-avatars-tab-icons/commit/72aa79e66edfc002bb241428b3c5d4246758ff1b:9
    window["__f__lk4jg1u3.dgq"]/< moz-extension://047311dd-ae1f-4370-b50a-d5d819e266b9/userscripts/Github-Commit-Diff.user.js?id=ef4782ed-174b-4e3c-acd5-007e4c3685bd:1
    "__f__lk4jg1u3.dgq" moz-extension://047311dd-ae1f-4370-b50a-d5d819e266b9/userscripts/Github-Commit-Diff.user.js?id=ef4782ed-174b-4e3c-acd5-007e4c3685bd:1
    St https://github.com/rybak/github-pr-avatars-tab-icons/commit/72aa79e66edfc002bb241428b3c5d4246758ff1b:9
    s https://github.com/rybak/github-pr-avatars-tab-icons/commit/72aa79e66edfc002bb241428b3c5d4246758ff1b:72
    <anonymous> https://github.com/rybak/github-pr-avatars-tab-icons/commit/72aa79e66edfc002bb241428b3c5d4246758ff1b:75
    g https://github.com/rybak/github-pr-avatars-tab-icons/commit/72aa79e66edfc002bb241428b3c5d4246758ff1b:69

Where b comes from:

            var b = e.querySelector('.toc-diff-stats')

CSS class toc-diff-stats isn't used anymore, but there is similar document.getElementById('toc'). Replacing the broken code like so:

            var b = document.getElementById('toc')

... puts the button on the left hand side of the page – see attached screenshot.

Tested on page https://github.com/rybak/github-pr-avatars-tab-icons/commit/72aa79e66edfc002bb241428b3c5d4246758ff1b

Firefox 114, Tampermonkey v4.19.0

Post reply

Sign in to post a reply.