Jump to content

User:Chlod/Scripts/ReferenceDeselector.js

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.
// ReferenceDeselector
// Author: Chlod
// Version: 1.0.0-REL

// Makes references unselectable for easy copy-pasting.

// By using this userscript, I am not liable for any plagiarism or copyright
// charges that you may incur at work or school as a result of using this 
// userscript. Suffer the consequences on your own.

(function () {
	const linkB = mw.util.addPortletLink( "p-cactions", "#", "Make references unselectable", "pt-unselectablerefs" );
	if(linkB) linkB.addEventListener( "click", function(e) { $( ".reference" ).css("user-select", "none"); e.preventDefault(); return false; } );
	const linkC = mw.util.addPortletLink( "p-cactions", "#", "Make references selectable", "pt-selectablerefs" );
	if(linkC) linkC.addEventListener( "click", function(e) { $( ".reference" ).css("user-select", "inherit"); e.preventDefault(); return false; } );
})();