From Wikipedia, the free encyclopedia
Note: After saving, you have to bypass your browser's cache to see the changes. Google Chrome, Firefox, Microsoft Edge and Safari: Hold down the ⇧ Shift key and click the Reload toolbar button. For details and instructions about other browsers, see Wikipedia:Bypass your cache.

// <nowiki>

// Jacked from Novem Linguae (User:Novem Linguae/CopyTitle.js) on December 1, 2021, to make the button pretty.



// Adds a "Copy" button next to every article title. Clicking it writes the article title to the clipboard.

// Script requested at WP:US/R by GreenC

// FYI, this script by Nardog does the same thing but has more features: /info/en/?search=User:Nardog/CopySectLink.js



function writeToClipboard(input) {

	var data = new ClipboardItem({ "text/plain": new Blob([input], { type: "text/plain" }) })];

	navigator.clipboard.write(data);

}



$('#firstHeading').append('&nbsp;&nbsp;<button id="copyTitle" style="margin-left: 1em;">c</button>');

document.getElementById("copyTitle").style = "font-family: monospace; font-size: 50%; padding: 1px; border: 1px; width: 1em; background:#B58900; color:#002b36";

$('#copyTitle').on('click', function() {

	// get title from API (easier than getting it from .html() and taking the tags out)

	let title = mw.config.get('wgPageName').replace(/_/g, ' ');

	

	navigator.clipboard.writeText(title);

});



// </nowiki>