User:Dybdeskarphet/common.js
Note: After publishing, you may have to bypass your browser's cache to see the changes.
- Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
- Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
- Internet Explorer / Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5
- Opera: Press Ctrl-F5.
// ==UserScript== // @name ArchWiki Copy Revision Number // @namespace http://tampermonkey.net/ // @version 0.1 // @description Add a button to copy the revision number in ArchWiki // @author YourName // @match *://wiki.archlinux.org/* // @grant none // ==/UserScript== (function() { 'use strict'; // Function to create and add the button function addCopyRevisionButton() { // Find the element that contains the revision number // This selector might need to be adjusted var revElement = document.querySelector('#footer-info-lastmod'); if (!revElement) return; var revisionNumber = revElement.textContent.match(/(\d+)/)[0]; if (!revisionNumber) return; // Create the copy button var copyButton = document.createElement('button'); copyButton.textContent = 'Copy Revision Number'; copyButton.style.marginLeft = '10px'; // Copy functionality copyButton.addEventListener('click', function() { navigator.clipboard.writeText(revisionNumber).then(function() { console.log('Revision number copied to clipboard:', revisionNumber); }, function(err) { console.error('Could not copy revision number:', err); }); }); // Append the button next to the revision element revElement.appendChild(copyButton); } // Add the button when the DOM is fully loaded document.addEventListener('DOMContentLoaded', addCopyButton); })();