User talk:Nardog/CopySectLink

Latest comment: 3 months ago by Aaron Liu in topic Request #2

Thanks edit

Thanks again for making this. I use it daily, saves a lot of hand moves from mouse to keyboard. GreenC 16:22, 24 December 2021 (UTC)Reply

Conflicts with "Add an [edit] link for the lead section of a page" edit

Love this script but sometimes (on page load), the script interferes with the "Add an [edit] link for the lead section of a page" gadget, and the spot next to the lead header reads as [ copy | copy ] rather than [ edit | copy ]. When it's messed up, clicking on the first "copy" runs this CopySectLink and copies to clipboard, and clicking the second "copy" reloads the page. Hard refreshing the page resolves the issue, but it happens pretty often—anyone else getting the same thing and any easy fixes? czar 01:20, 18 January 2022 (UTC)Reply

I'm aware of this issue. It occurs when this script is run before the edittop gadget. It can be fixed by making sure the script is loaded after the gadget, as in:
mw.loader.using('ext.gadget.edittop', function () {
	mw.loader.load('//en.wikipedia.org/w/index.php?title=User:Nardog/CopySectLink.js&action=raw&ctype=text/javascript');
});
I'll update the documentation. Nardog (talk) 01:59, 18 January 2022 (UTC)Reply
@Czar: Seeing how popular the gadget seems to be across wikis, I've decided to make the script automatically avoid the conflict. You no longer have to use the above code. Nardog (talk) 08:34, 19 January 2022 (UTC)Reply

Thanks & Request? edit

I love this script! Could the "copy" button be renamed to "link", though? I get that users who install this script know what they expect, but it could be slightly confusing- in screenshots, I guess? Aaron Liu (talk) 02:21, 20 December 2023 (UTC)Reply

I don't know how that could be the case. "edit" initiates the process of editing the section, and "copy" initiates the process of copying the section path. It's pretty self-explanatory, more so than "link". Anyway, you can always fork a script yourself if you don't like something about it. Nardog (talk) 14:15, 20 December 2023 (UTC)Reply

Request #2 edit

Could the script perhaps make the "copy" link's href be something like just "#" so it doesn't look like it's been visited? Aaron Liu (talk) 21:51, 12 January 2024 (UTC)Reply

As the documentation says, it's deliberately linked to the section itself so you can also copy the full URL by right-clicking it and selecting the browser's native "Copy link". Nardog (talk) 21:57, 12 January 2024 (UTC)Reply
Ah, that makes sense, I'll have to read better next time :p Should this thing have a style that removes the purple (or even better, only show purple when you've copied) then? Aaron Liu (talk) 22:03, 12 January 2024 (UTC)Reply