I was inspired by @TypoTonic:
Referencing quotes/text snippets and @TryNinja:
[UserScript] Copy post quote snip to clipboard (with browser highlight URL) to come up with this thread on how to make use of scripts in both Desktop and Android.
I am a newbie when I first saw this, it inspired me so much which was why I wanted to break it down for my colleague (newbies) to get it without any stress. I have make thorough research on getting some of the browsers both in desktop and Android that will work with tempermonkey extension with out any challenges.
I don't have any proof but I believe majority of the users here use mobile phone to access this forum and it will be very nice to see them enjoying this features because to be honest it make posting easier when it comes to quoting someone.
Below are the list of browsers which I found for both Desktop and Android that accept tempermonkey extension.
1. Kiwi browser
2.
Lemur Browser - Extensions 3.
XBrowser - Mini & Super fast 4.
Microsoft Edge: Al Browser 5.
Firefox Fast & Private Browser 6.
Via Browser - Fast & Light I have listed six browsers that supported tempermonkey extension among them all is only Firefox Fast that I've tried in the desktop and it gave me a perfect result. Kiwi browser is no more in existence that is why I could not be able to provide it link.
I will be showing the practical aspect of it so that it will be easier when you are using any of them browsers.
1. XBrowser, Via Browser and Microsoft Edge : These browsers came with their own tempermonkey extensions, the only thing that is required here, go to their main menu, you will see extension, this is for both Microsoft Edge and XBrowser - Mini & Super fast. For Via Browser go directly to setting you will see script.
2. Firefox Fast, Lemur Browser - Extensions and Kiwi browser : These browsers you have to download the extension through
here . I think by now you have know how to download your tempermonkey extension.
We will be discussing practically on how to import your script in your tempermonkey extension.
There are many ways to import script in the extension, which I listed below
1. NewScript
2. Add from User Sharing
3. Import script from url
4. Import from File
5. Install from GreasyFork
As regard to the topic I will only Focus on the New Script which we will copy it and paste it directly.
Here is the script
// ==UserScript==
// @name BitcoinTalk Quick Quote with Text-Fragment (Mobile Fix)
// @version 1.2
// @description Quickly copy a quote snippet to your clipboard. Optimized for Mobile/Kiwi.
// @author TryNinja
// @match https://bitcointalk.org/index.php?topic=*
// @icon https://bitcointalk.org/favicon.ico
// @grant GM_setClipboard
// ==/UserScript==
(function () {
'use strict';
let currentSelectionContext = null;
let selectionTimeout;
const btn = document.createElement('button');
btn.textContent = '❝ Copy Quote';
btn.style.position = 'absolute';
btn.style.display = 'none';
btn.style.zIndex = '9999';
btn.style.padding = '8px 12px';
btn.style.backgroundColor = '#e7eaef';
btn.style.border = '1px solid #000';
btn.style.borderRadius = '5px';
btn.style.cursor = 'pointer';
btn.style.fontSize = '14px';
btn.style.fontWeight = 'bold';
btn.style.boxShadow = '0px 4px 10px rgba(0,0,0,0.3)';
btn.addEventListener('mousedown', function(e) { e.preventDefault(); e.stopPropagation(); });
btn.addEventListener('touchstart', function(e) { e.preventDefault(); e.stopPropagation(); }, { passive: false });
btn.addEventListener('click', function(e) {
e.preventDefault();
if (currentSelectionContext) {
processQuote(currentSelectionContext.postDiv, currentSelectionContext.text, btn);
}
});
btn.addEventListener('touchend', function(e) {
e.preventDefault();
if (currentSelectionContext) {
processQuote(currentSelectionContext.postDiv, currentSelectionContext.text, btn);
}
});
document.body.appendChild(btn);
function hideButton() {
btn.style.display = 'none';
currentSelectionContext = null;
}
function handleSelection() {
const selection = window.getSelection();
const selectedText = selection.toString().trim();
if (selectedText.length < 1) {
hideButton();
return;
}
let node = selection.anchorNode;
if (node && node.nodeType === 3) node = node.parentNode;
const postDiv = node.closest('div.post');
if (!postDiv) {
hideButton();
return;
}
currentSelectionContext = {
postDiv: postDiv,
text: selectedText
};
try {
const range = selection.getRangeAt(0);
const rect = range.getBoundingClientRect();
const topPos = window.scrollY + rect.bottom + 10;
let leftPos = window.scrollX + rect.left + (rect.width / 2) - (btn.offsetWidth / 2);
if (leftPos < 10) leftPos = 10;
btn.style.top = `${topPos}px`;
btn.style.left = `${leftPos}px`;
btn.style.display = 'block';
} catch (e) {
console.error(e);
hideButton();
}
}
document.addEventListener('selectionchange', function () {
clearTimeout(selectionTimeout);
selectionTimeout = setTimeout(handleSelection, 250);
});
document.addEventListener('touchstart', function (e) {
if (e.target !== btn && !btn.contains(e.target)) {
hideButton();
}
}, { passive: true });
function safeEncode(str) {
return encodeURIComponent(str).replace(/'/g, '%27');
}
function generateTextFragment(text) {
const cleanText = text.replace(/\s+/g, ' ');
const words = cleanText.split(' ');
if (words.length <= 8) {
return safeEncode(cleanText);
}
const textStart = words.slice(0, 4).join(' ');
const textEnd = words.slice(-4).join(' ');
return `${safeEncode(textStart)},${safeEncode(textEnd)}`;
}
function getFormattedDateString() {
const date = new Date();
const months = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"];
return `${months[date.getMonth()]} ${date.getDate()}, ${date.getFullYear()}`;
}
function processQuote(postDiv, selectedText, buttonElement) {
try {
const contentTd = postDiv.closest('td.td_headerandpost');
if (!contentTd) throw new Error("Could not find post");
const authorTd = contentTd.previousElementSibling;
let authorName = "Unknown";
if (authorTd && authorTd.classList.contains('poster_info')) {
const aElement = authorTd.querySelector('b > a');
if (aElement) authorName = aElement.textContent.trim();
}
let permalink = "";
const subjectDiv = contentTd.querySelector('div.subject');
if (subjectDiv) {
const linkElem = subjectDiv.querySelector('a');
if (linkElem) permalink = linkElem.href;
}
if (!permalink) {
const anchorLink = contentTd.querySelector('a[href*="#msg"]');
if (anchorLink) permalink = anchorLink.href;
}
if (permalink) {
const parts = permalink.split('#');
let cleanBase = parts[0].split(';')[0];
if (parts[1]) permalink = cleanBase + '#' + parts[1];
}
let rawDate = "";
if (subjectDiv && subjectDiv.parentElement) {
const smallTextDiv = subjectDiv.parentElement.querySelector('.smalltext');
if (smallTextDiv) rawDate = smallTextDiv.textContent.trim();
}
if (rawDate.startsWith("Today")) {
const fullDate = getFormattedDateString();
rawDate = rawDate.replace("Today", fullDate).replace(" at ", ", ");
}
const fragment = generateTextFragment(selectedText);
const dateStr = rawDate || "Unknown Date";
const authorStr = authorName || "Unknown Author";
const finalUrl = `${permalink}#:~:text=${fragment}`;
const quoteHeader = `[url=${finalUrl}]${authorStr} on ${dateStr}[/url]`;
const bbcode = `[quote="${quoteHeader}"]\n${selectedText}\n[/quote]`;
GM_setClipboard(bbcode);
const originalText = buttonElement.textContent;
buttonElement.textContent = "Copied!";
buttonElement.style.backgroundColor = "#dff0d8";
buttonElement.style.color = "#3c763d";
setTimeout(() => {
buttonElement.textContent = originalText;
buttonElement.style.backgroundColor = "#e7eaef";
buttonElement.style.color = "#000";
hideButton();
}, 1000);
} catch (err) {
console.error("Quote Error:", err);
buttonElement.textContent = "Error";
buttonElement.style.backgroundColor = "#f2dede";
}
}
})();
How to insert it on tempermonkey extension
1. Firstly, download the extension from the link above.
After downloading, enable the developer mode
2. Open the tempermonkey to import script.
3. Click on create a new script and it will open like this :
Then import the script above.
Then save by clicking file above.
After saved, it will appear like this
Go back to the main menu see whether it will appear but before that, go to settings and change configuration mode to Advanced
See my result
Like I said at the beginning, I'm still a newbie I just tried my best to put this together if there's any mistake I stand to be corrected.
Thanks to both @TryNinja and @TypoTonic for this wonderful contributions to the forum.