// ==UserScript== // @name Bitcointalk Paste URL Formatter // @namespace https://bitcointalk.org/ // @version 1.3 // @description Automatically formats copy/pasted URLs as [url=URL]change_text[/url] BBCode. Press Ctrl+Shift+U to enable or disable. // @match https://bitcointalk.org/index.php?action=post* // @grant none // @author PX-Z // ==/UserScript== (function () { 'use strict'; function addStyles() { const style = document.createElement('style'); style.textContent = ` #url_formatter_note_text { padding: 3px 15px; border: 1px solid #e2cf6b; background: #fffbe4; } #url_formatter_toggle { margin-left: 8px; } `; document.head.appendChild(style); } let enabled = true; // Update the note text function updateNote() { const noteText = document.querySelector('#url_formatter_note_text'); if (!noteText) { return; } noteText.innerHTML = enabled ? 'Note: URL Formatter is ON. Press Ctrl+Shift+U to disable. Or clickDisable' : 'Note: URL Formatter is OFF. Press Ctrl+Shift+U to enable. Or clickEnable'; const toggle = document.querySelector('#url_formatter_toggle'); if (toggle) { toggle.addEventListener('click', function (e) { e.preventDefault(); enabled = !enabled; updateNote(); }); } } // Add note after #lock_warning function addNote() { const lockWarning = document.querySelector('#lock_warning'); if (!lockWarning) { return; } // Prevent duplicate note if (document.querySelector('#url_formatter_note')) { return; } const noteRow = document.createElement('tr'); noteRow.id = 'url_formatter_note'; noteRow.innerHTML = `