Jump to content

User:Awesome Aasim/copycodeblock

From Wikipedia, the free encyclopedia
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.
copycodeblock
UpdatedAugust 27, 2024
    (8 months 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

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

on Wikipedia. Or,

mw.loader.load("https://en.wikipedia.org/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.