GitHub-userscripts icon indicating copy to clipboard operation
GitHub-userscripts copied to clipboard

GitHub Issue Add Details - no longer works

Open darkred opened this issue 4 years ago • 3 comments

The 'GitHub Issue Add Details ' script no longer works (in existing or new comments of issue/pull requests). Instead it shows in Console this error:

TypeError: Cannot read properties of null (reading 'parentNode')

referring to line 44:

https://github.com/Mottie/GitHub-userscripts/blob/4983620a1661d204b675d82b2192c7ebbb16bbbc/github-issue-add-details.user.js#L44

Tested in a fresh Chrome profile witn only TM/VM installed.

darkred avatar Oct 24 '21 18:10 darkred

Thanks @darkred!

I keep meaning to update the code, but have been overly busy :(

Try this change:

  // Add insert details button
	function addDetailsButton() {
		const button = document.createElement("button");
		button.type = "button";
		button.className = "ghad-details toolbar-item tooltipped tooltipped-n";
		button.setAttribute("aria-label", "Add a details/summary block");
		button.setAttribute("tabindex", "-1");
		button.innerHTML = icon;
		[...document.querySelectorAll(".toolbar-commenting")].forEach(el => {
			if (el && !$(".ghad-details", el)) {
				const btn = $("[aria-label*='Add a task list']", el);
				btn.before(button.cloneNode(true));
			}
		});
	}

Mottie avatar Oct 24 '21 18:10 Mottie

Thank you for your quick response!

I tested it and it works ok in New Issue/PR forms and in existing Issues/PRs | New Comment form

If you would be so kind, when you have the chance, could you make it also work when editing existing comments in issues/PRs, please?

darkred avatar Oct 24 '21 19:10 darkred

I finally got around to updating the userscript, but I didn't add the enhancement you requested... once I find some more free time! 😞

Mottie avatar Nov 30 '21 14:11 Mottie