User:Awesome Aasim/copycodeblock

copycodeblock
UpdatedAugust 27, 2024
    (1 day ago)
SourceUser:Awesome Aasim/copycodeblock.js

Allows for convenient copy-paste of code blocks with syntaxhighlighting without having to open the source or select the text.

Originally developed on Fandom, then incorporates some of User:Nardog/CopyCodeBlock in.

Note: Clipboard permissions are recommended in order to prevent duplicate items from being copied. This is useful if you are using a clipboard manager such as Windows Clipboard History or the Office Clipboard.

Install

edit
importScript("User:Awesome Aasim/copycodeblock.js")

on Wikipedia. Or,

mw.loader.load("https://en.wiki.x.io/wiki/User:Awesome Aasim/copycodeblock.js?action=raw&ctype=text/javascript")

on other Wikimedia projects. Note: The latter will definitely require clipboard permissions due to how Chromium and Firefox based browsers handle copy and paste cross origin.

A copy is also hosted on Fandom as well:

mw.loader.load("https://dev.fandom.com/wiki/User:Awesome Aasim/copycodeblock.js?action=raw&ctype=text/javascript")

Note: If you are not using this on a wiki with the latest version of OOUI, you might see blocks instead of actual copy icons in the corner. Functionality remains the same.