Bitcointalk Locked Thread Popup + Live Detection
This topic came to my attention a minute ago, I wanted to create a script on it a long time ago, but due to lack of time and laziness I didn't do it.
But today I tried it with the help of AI.
The Feature of this script is-- If you accidentally go to create a post on a locked topic without noticing that the topic is locked, a popup message will appear informing you that the topic is locked.
- Another special feature of this is that if you are writing a post on a topic and the moderator locks it, then within five seconds it will show you a popup notification that the topic has been locked.
This way, at least you won't have to waste your time after the topic is locked.
And to use this script, you need to download tampermonkey and then open it.then,
Create a new script> copy this code and paste and save> now enjoyOr you can directly add to tamperkmoney by one clicking-
Bitcointalk Locked Thread Popup + Live Detection leasted version// ==UserScript==
// @name Bitcointalk Locked Thread Popup + Live Detection leasted version
// @namespace https://bitcointalk.org/
// @version 3.0
// @description Show a modern popup if a thread is locked or becomes locked while writing.
// @author Crypto Library
// @homepageURL https://bitcointalk.org/
// @supportURL https://bitcointalk.org/index.php?action=profile
// @match https://bitcointalk.org/index.php?action=post*
// @grant GM_xmlhttpRequest
// @connect bitcointalk.org
// ==/UserScript==
(function () {
'use strict';
const CHECK_INTERVAL = 5000;
let popupShown = false;
// ------------------------
// Popup
// ------------------------
function showPopup() {
if (popupShown) return;
popupShown = true;
const overlay = document.createElement("div");
overlay.style.cssText = `
position:fixed;
inset:0;
background:rgba(0,0,0,.55);
display:flex;
justify-content:center;
align-items:center;
z-index:999999;
animation:fadeIn .25s ease;
`;
const popup = document.createElement("div");
popup.style.cssText = `
width:420px;
max-width:90%;
background:#fff;
border-radius:14px;
padding:28px;
text-align:center;
box-shadow:0 12px 35px rgba(0,0,0,.35);
animation:pop .25s ease;
font-family:Arial,sans-serif;
`;
popup.innerHTML = `
<div style="font-size:60px;">🔒</div>
<h2 style="margin:10px 0;color:#d32f2f;">
Thread Locked
</h2>
<p style="font-size:15px;color:#444;line-height:1.6;">
This topic has been locked.<br><br>
You cannot submit your reply anymore.
</p>
<button id="btcPopupOK"
style="
margin-top:20px;
padding:10px 30px;
border:none;
border-radius:8px;
background:#1976d2;
color:white;
font-size:15px;
cursor:pointer;
">
OK
</button>
`;
overlay.appendChild(popup);
document.body.appendChild(overlay);
function closePopup() {
overlay.remove();
}
document.getElementById("btcPopupOK").onclick = closePopup;
document.addEventListener("keydown", function esc(e) {
if (e.key === "Escape") {
closePopup();
document.removeEventListener("keydown", esc);
}
});
}
// ------------------------
// CSS
// ------------------------
const style = document.createElement("style");
style.textContent = `
@keyframes fadeIn{
from{opacity:0;}
to{opacity:1;}
}
@keyframes pop{
from{
transform:scale(.8);
opacity:0;
}
to{
transform:scale(1);
opacity:1;
}
}
`;
document.head.appendChild(style);
// ------------------------
// Get Topic ID
// ------------------------
const match = location.href.match(/topic=(\d+)/);
if (!match) return;
const topicId = match[1];
let lastState = null;
// ------------------------
// Detect Locked State
// ------------------------
function parseLocked(html) {
const doc = new DOMParser().parseFromString(html, "text/html");
const links = [...doc.querySelectorAll("a")];
const hasReply = links.some(a =>
a.textContent.trim().toLowerCase() === "reply"
);
return !hasReply;
}
// ------------------------
// Check Thread
// ------------------------
function checkThread() {
GM_xmlhttpRequest({
method: "GET",
url: `https://bt.irlbtc.com/view/${topicId}.0&_=${Date.now()}`,
headers: {
"Cache-Control": "no-cache"
},
onload: function (r) {
if (r.status !== 200) return;
const locked = parseLocked(r.responseText);
// Initial check
if (lastState === null) {
lastState = locked;
if (locked) {
showPopup();
}
return;
}
// Unlocked -> Locked
if (lastState === false && locked) {
showPopup();
}
lastState = locked;
}
});
}
// Initial check
checkThread();
// Live monitoring
setInterval(checkThread, CHECK_INTERVAL);
})();
Output