Bitcoin Forum
September 02, 2026, 02:28:50 AM *
News: Latest Bitcoin Core release: 31.1 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: [Userscript] Bitcointalk Post Saver, Keep Your Writing Safe.  (Read 197 times)
Royal Cap (OP)
Sr. Member
****
Offline

Activity: 560
Merit: 270



View Profile WWW
August 31, 2026, 10:22:08 PM
Merited by Mia Chloe (3)
 #1

A few days ago, I was writing a post on this forum. I had already spent quite some time writing it, and the post was almost finished, then I accidentally refreshed the page. After the refresh, I saw that everything I had written was gone. It is worth mentioning that I had not clicked the Preview Button, so the forum's own draft system had not saved my post either. After this happened, I was thinking that it would be useful to have a simple userscript that automatically saves your draft while you are typing. So I ended up making this small script for myself.

Although Tryninja has already made a script for this, his script mainly works by using the Preview option. Basically, it calls the Preview button in the background every few seconds and saves the post as a forum draft. Because of this, you still need to go to the Draft option and copy that post again.

Script Overview
This script automatically saves whatever you are writing while creating a post or reply on Bitcointalk to your browser's local storage. So, even if you accidentally refresh the page, close the tab, or lose the writing area for any other reason, you can restore your saved draft when you open the same page again.

I know that Bitcointalk's Preview option already saves the post as a draft. This is a very useful feature. But the problem is that we often forget to click the Preview button while writing. I was having exactly this problem myself.

So I thought, why not make it so that Preview does not need to be done manually? I can simply keep typing, and the script will save the draft automatically.

Features
  • Draft is automatically saved while typing (Does not use the forum's draft feature)
  • Saved draft is automatically restored after refreshing the page. This also means even if you come back to the same reply page after 1 day, your saved post will still be there unless you click the Clear button.
  • Drafts older than 7 days are automatically deleted
  • Saved draft is automatically deleted after submitting the post
  • Shows a warning when the post exceeds the 64,000 character limit, because a forum's post can contain a maximum of 64,000 characters. (This is especially useful for people who write large posts.)

Separate Drafts for Each Post : One of the useful parts of this script is that each topic or reply page gets its own separate draft. For example, if you're writing a reply on Topic A and then start writing another reply on Topic B, both drafts are saved independently. Your Topic A draft will not overwrite the Topic B draft.


Demo
 

Installation Process
  • Install Tampermonkey.
  • Create a new script.
  • Paste the code below.
  • Save the script and reload any Bitcointalk thread.
  • Or use the Greasy Fork link for one click installation.
  • Now open any Bitcointalk topic and go to the Reply or New Topic page.
  • You will see the word/character counter and draft status below the textarea.

For Mobile Devices

The process is almost the same. You just need to use Firefox for Android

Then, when you write a post on Bitcointalk, the script will work automatically.

Code:
// ==UserScript==
// @name         Bitcointalk Minimalist Auto-Save Draft
// @version      1.0
// @description  Auto-save draft with auto-expiration (7 days) and 64,000 character limit warning
// @author       Royal Cap
// @match        https://bitcointalk.org/index.php?*action=post*
// @match        https://bitcointalk.org/index.php?*topic=*
// @grant        none
// @license MIT
// @namespace https://greasyfork.org/users/1507638
// ==/UserScript==

(function() {
    'useStrict';

    const textarea = document.querySelector('textarea[name="message"]');
    if (!textarea) return;

    const storageKey = 'btt_draft_' + window.location.href;
    const warnLimit = 64000; // Bitcointalk maximum post length
    const maxAge = 7 * 24 * 60 * 60 * 1000; // Delete After 7 Days
    let saveTimeout = null;

    const uiContainer = document.createElement('div');
    uiContainer.style.cssText = 'margin-top: 4px; font-size: 11px; font-family: verdana, sans-serif; color: #444; display: flex; align-items: center; justify-content: space-between;';

    const leftGroup = document.createElement('div');
    leftGroup.style.cssText = 'display: flex; align-items: center; gap: 8px;';

    const clearBtn = document.createElement('button');
    clearBtn.type = 'button';
    clearBtn.textContent = 'Clear Draft';
    clearBtn.style.cssText = 'padding: 1px 5px; font-size: 12px; font-family: verdana, sans-serif; background: #e0e0e0; color: #000; border: 1px solid #999; cursor: pointer; display: none;';

    const statusText = document.createElement('span');
    statusText.style.fontStyle = 'italic';
    statusText.style.color = '#666';

    leftGroup.appendChild(clearBtn);
    leftGroup.appendChild(statusText);

    const countDisplay = document.createElement('div');
    countDisplay.style.cssText = 'font-weight: normal; color: #555; margin-right: 50px;';

    uiContainer.appendChild(leftGroup);
    uiContainer.appendChild(countDisplay);

    textarea.parentNode.insertBefore(uiContainer, textarea.nextSibling);

    function updateCounter() {
        const text = textarea.value;
        const charCount = text.length;
        const wordCount = text.trim() ? text.trim().split(/\s+/).length : 0;

        if (charCount > warnLimit) {
            countDisplay.innerHTML = `<span style="color: red; font-weight: bold;">Words: ${wordCount} | Chars: ${charCount} (Exceeding ${warnLimit} limit!)</span>`;
        } else {
            countDisplay.innerHTML = `Words: <b>${wordCount}</b> | Chars: <b>${charCount}</b> / ${warnLimit}`;
        }
    }

    function toggleClearBtn() {
        const savedData = localStorage.getItem(storageKey);
        if (savedData) {
            clearBtn.style.display = 'inline-block';
        } else {
            clearBtn.style.display = 'none';
        }
    }


    const rawData = localStorage.getItem(storageKey);
    if (rawData) {
        try {
            const parsedData = JSON.parse(rawData);

            if (Date.now() - parsedData.timestamp > maxAge) {
                localStorage.removeItem(storageKey);
                statusText.textContent = 'Expired draft deleted';
            } else {
                textarea.value = parsedData.text;
                statusText.textContent = 'Draft restored';
            }
        } catch (e) {

            textarea.value = rawData;
            statusText.textContent = 'Draft restored';
        }
    }

    updateCounter();
    toggleClearBtn();

    textarea.addEventListener('input', function() {
        updateCounter();
        statusText.textContent = 'Saving...';

        clearTimeout(saveTimeout);
        saveTimeout = setTimeout(() => {
            if (textarea.value.trim() === '') {
                localStorage.removeItem(storageKey);
                statusText.textContent = 'Draft empty';
            } else {

                const dataToSave = {
                    text: textarea.value,
                    timestamp: Date.now()
                };
                localStorage.setItem(storageKey, JSON.stringify(dataToSave));
                const timeStr = new Date().toLocaleTimeString([], { hour: '2-digit', minute: '2-digit' });
                statusText.textContent = `Saved at ${timeStr}`;
            }
            toggleClearBtn();
        }, 500);
    });

    clearBtn.addEventListener('click', function() {
        if (confirm('Clear saved draft?')) {
            localStorage.removeItem(storageKey);
            textarea.value = '';
            updateCounter();
            statusText.textContent = 'Draft cleared';
            toggleClearBtn();
        }
    });

    const form = textarea.closest('form');
    if (form) {
        form.addEventListener('submit', function() {
            localStorage.removeItem(storageKey);
        });
    }
})();



This script only uses the browser's localStorage. So, if you clear the site's data or local storage, your saved drafts may also be deleted. Another thing is that the draft key is created based on the same URL. So, drafts from different post/reply pages will be stored separately.



Vod
Legendary
*
Offline

Activity: 4508
Merit: 3705


Licking my boob since 1970


View Profile WWW
August 31, 2026, 10:56:21 PM
 #2

A few days ago, I was writing a post on this forum. I had already spent quite some time writing it, and the post was almost finished, then I accidentally refreshed the page.

When this happens to me, sometimes the back button restores everything.

███████████████████████████
███████▄████████████▄██████
████████▄████████▄████████
███▀█████▀▄███▄▀█████▀███
█████▀█▀▄██▀▀▀██▄▀█▀█████
███████▄███████████▄███████
███████████████████████████
███████▀███████████▀███████
████▄██▄▀██▄▄▄██▀▄██▄████
████▄████▄▀███▀▄████▄████
██▄███▀▀█▀██████▀█▀███▄███
██▀█▀████████████████▀█▀███
███████████████████████████
.
.Duelbits PREDICT..
█████████████████████████
█████████████████████████
███████████▀▀░░░░▀▀██████
██████████░░▄████▄░░████
█████████░░████████░░████
█████████░░████████░░████
█████████▄▀██████▀▄████
████████▀▀░░░▀▀▀▀░░▄█████
██████▀░░░░██▄▄▄▄████████
████▀░░░░▄███████████████
█████▄▄█████████████████
█████████████████████████
█████████████████████████
.
.WHERE EVERYTHING IS A MARKET..
█████
██
██







██
██
██████
Will Bitcoin hit $200,000
before January 1st 2027?

    No @1.15         Yes @6.00    
█████
██
██







██
██
██████

  CHECK MORE > 
BitMaxz
Legendary
*
Offline

Activity: 4088
Merit: 3681


♻️ Automatic Exchange


View Profile WWW
August 31, 2026, 11:22:18 PM
 #3

When this happens to me, sometimes the back button restores everything.

It does not work when you accidentally click Reload. Everything you wrote, including the subject title, is completely gone, and the back button cannot save them.

░░░░▄▄████████████▄
▄████████████████▀
▄████████████████▀▄█▄
▄██████▀▀░░▄███▀▄████▄
▄██████▀░░░▄███▀▀██████▄
██████▀░░▄████▄░░░▀██████
██████░░▀▀▀▀▄▄▄▄░░██████
██████▄░░░▀████▀░░▄██████
▀██████▄▄███▀░░░▄██████▀
▀████▀▄████░░▄▄███████▀
▀█▀▄████████████████▀
▄████████████████▀
▀████████████▀▀░░░░
 
 CCECASH 
ryzaadit
Legendary
*
Online Online

Activity: 3304
Merit: 1450



View Profile WWW
August 31, 2026, 11:24:52 PM
 #4

When this happens to me, sometimes the back button restores everything.
It's Chrome's Back/Forward Cache.

But, these sometimes will not work at the time you're accidently refresh the page. Like F5, or clicking "Reload this page" either the page blank or you will go to the thread you want to post.

However, Chrome's Back/Forward Cache might work if you accidently go to other page like miss clicked to other page. This stuff, we can tested too.
- F12
- Go to Application
- In the left, try to looks: Background services
- Looks Back/forward cache.
- Feels to Run Test.


▄▄███████████████████▄▄
▄███████████████████████▄
████████████████████████
█████████████████████████
████████████████████████
████████████▀██████▀████
████████████████████████
█████████▄▄▄▄███████████
██████████▄▄▄████████████
████████████████████████
████████████████▀▀███████
▀███████████████████████▀
▀▀███████████████████▀▀
 
 EARNBET 
| 🏀
 
🏈 🏓
 
🎯 🥊
 
 🎾
 
 🏐
 
🏏 🏎️
|


███████▄▄███████████
████▄██████████████████
██▀▀███████████████▀▀███
▄████████████████████████
▄▄████████▀▀▀▀▀████████▄▄██
███████████████████████████
█████████▌██▀████████████
███████████████████████████
▀▀███████▄▄▄▄▄█████████▀▀██
▀█████████████████████▀██
██▄▄███████████████▄▄███
████▀██████████████████
███████▀▀███████████

....HIGHEST....
VIP REWARDS

  G U A R A N T E E D  
| 
 🜲 
KING OF
THE CASTLE

$200K in prizes
| 
..PLAY NOW..
promise444c5
Legendary
*
Offline

Activity: 1120
Merit: 1115


All things are numbers


View Profile WWW
September 01, 2026, 12:15:37 AM
 #5

When this happens to me, sometimes the back button restores everything.

It does not work when you accidentally click Reload. Everything you wrote, including the subject title, is completely gone, and the back button cannot save them.
He mentioned “sometimes” though..  hitting the refresh button isn’t really that common like how mobile browser automatically refreshes  and wiping the text field after peeping outside Bitcointalk tab but yeah it surely does happen.

Apart from the main TryNinja’s code, there’s another version I modified for we lazy people Grin..  displays a preview along [a mod of the original script ] : https://bitcointalk.org/index.php?topic=5576527.msg66478287#msg66478287 .

OP’s code interacts with the LS which is another option ..



tbct_mt2
Legendary
*
Offline

Activity: 3080
Merit: 1077



View Profile
September 01, 2026, 04:41:54 AM
 #6

Features
  • Draft is automatically saved while typing (Does not use the forum's draft feature)
  • Saved draft is automatically restored after refreshing the page. This also means even if you come back to the same reply page after 1 day, your saved post will still be there unless you click the Clear button.
  • Drafts older than 7 days are automatically deleted
  • Saved draft is automatically deleted after submitting the post
  • Shows a warning when the post exceeds the 64,000 character limit, because a forum's post can contain a maximum of 64,000 characters. (This is especially useful for people who write large posts.)
More information about the forum draft page.
Draft page - Pros & Cons.

Your user script is helpful for people who are ready to use user script and don't want to draft their posts in other softwares before copying and pasting it to the forum for publishing their posts. It's very helpful for them as directly composing posts in the forum can cause post content loss if there is issue with connection and forget of clicking on Preview.

 
 POWER.WIN 












 
























 
 PLAY NOW 
un_rank
Legendary
*
Offline

Activity: 1554
Merit: 1115



View Profile WWW
September 01, 2026, 03:09:47 PM
 #7

I have been using TryNinja's script since it was introduced and it has worked perfectly for the intended purpose. It doesn't hurt to have multiple resources for a single problem, we have it for many other scripts on the forum, so it's welcome for this too.
Yours also has the edge of saving directly on the page and not to the draft list which has some downsides of quickly filling up the draft space and it sometimes being difficult to get the version of a post you want to restore when they all look very familiar.

I like minimalist looks for pages here, the word counter with the red colour will be off putting to me for every message I write. It only helps a few members who type long posts, many of whom will already use external sources for their writing and then paste it here.

- Jay -

█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████
█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████
█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████
█████████████████████▀█▀████████████████▀████████████████▀█████████████████████████████▀████████████████████████████████
█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████
████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████
███████████████████████████████████████████████████████████████████████████████████████████████████████████████████████
███████████████████████████████████████████████████████████████████████████████████████████▀██████▀█████▀████████▀█████
██████████████████████████████████████████████████████████████████████████████████████████████████████████████████
█████████████████████▄█▄████████████████▄████████████████▄█████████████████████████████████▄██████▄█████▄████████████
█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████
█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████
█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████
 
 🍒   ⚽️    IIIIIFASTEST GROWING CASINO & SPORTSBOOK     Play Now    
MisFoxie
Full Member
***
Offline

Activity: 272
Merit: 123



View Profile
September 01, 2026, 03:55:12 PM
 #8

I tried using your tool, and it is actually useful, but not in every case. Your tool will be very helpful when the page gets refreshed or closed somehow while writing but if some text gets selected and removed somehow there is no way to restore it.

And I really liked the text limit feature and it works very well for English words but when I test with it other local languages it doesn't work at all.

LTU_btc
Legendary
*
Offline

Activity: 3892
Merit: 1559


Slava Ukraini!


View Profile WWW
September 01, 2026, 05:27:54 PM
 #9

It does not work when you accidentally click Reload. Everything you wrote, including the subject title, is completely gone, and the back button cannot save them.
Don't know, maybe it depends on browser, but I just checked on Firefox - my main browser. Tried to click reload button in browser and also F5 and in both cases stuff that I wrote before didn't disappear.
Anyway, I think this script is going to be useful, probably significant part of users faced such thing at least once.

DYING_S0UL
Legendary
*
Offline

Activity: 1134
Merit: 1208


The Alliance Of Bitcointalk Translator - AOBT


View Profile WWW
September 01, 2026, 06:10:54 PM
 #10

Who accidentally refreshes the tab while posting! LOL Roll Eyes! Cause I don't, it's either preview or post for me.

What's the interval of each saves? I don't wanna accidentally press backspace and have the tool save a blank page. You know what I mean! Or is there multiple versions of saves for the same post? Multiple versions for the same things would be nice. Like each versions having 1 minutes of intervals, and max 5 versions. And after it reaches the 5th one, the very 1st one gets deleted and a new latest one gets added.

That 64,000 characters limit you say (also bear in mind, 65535 bytes in size) is only for "English" language! So can your script calculate the local posts? Many non English language takes more space and weight. For example "Bangla" takes 3x the space than "English". So I can only write about 24-25k characters. I'll be hitting the post size limit of 64kb, long before I hit the 64k character limit.

Now I did not used your tool, so another question is where does this draft gets saved on? From where I can access the saved content? (saw the Gifs, but they weren't clear to me).

▄▄███████████████████▄▄
▄███████████████████████▄
████████████████████████
█████████████████████████
████████████████████████
████████████▀██████▀████
████████████████████████
█████████▄▄▄▄███████████
██████████▄▄▄████████████
████████████████████████
████████████████▀▀███████
▀███████████████████████▀
▀▀███████████████████▀▀
 
 EARNBET 
██
██
██
██
██
██
██
██
██
██
██
██
██
███████▄▄███████████
████▄██████████████████
██▀▀███████████████▀▀███
▄████████████████████████
▄▄████████▀▀▀▀▀████████▄▄██
███████████████████████████
█████████▌██▀████████████
███████████████████████████
▀▀███████▄▄▄▄▄█████████▀▀██
▀█████████████████████▀██
██▄▄███████████████▄▄███
████▀██████████████████
███████▀▀███████████
██
██
██
██
██
██
██
██
██
██
██
██
██


▄▄▄
▄▄▄███████▐███▌███████▄▄▄
█████████████████████████
▀████▄▄▄███████▄▄▄████▀
█████████████████████
▐███████████████████▌
███████████████████
███████████████████
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀

 King of The Castle 
 $200,000 in prizes
██
██
██
██
██
██
██
██
██
██
██
██
██

 62.5% 

 
RAKEBACK
BONUS
Mia Chloe
Legendary
*
Offline

Activity: 1176
Merit: 2287


Contact me for your designs...


View Profile
September 01, 2026, 06:15:12 PM
 #11

~snip
Like I always say thumbs up for the effort you put in. That aside, I have encountered this problem multiple times to the extent I actually got two ways work around it and avoid losing all my text. The first is hitting preview at intervals when I type and the second is just copying everything to my clipboard.

Another thing I noticed is you'll only lose your text if you refresh an already existing page but if I use links and URLs to access other pages if I hit the back button the correct number of times I'll eventually get back to the page with my text intact only the post button may not work till you refresh.

BitMaxz
Legendary
*
Offline

Activity: 4088
Merit: 3681


♻️ Automatic Exchange


View Profile WWW
September 01, 2026, 11:55:46 PM
 #12

Don't know, maybe it depends on browser, but I just checked on Firefox - my main browser. Tried to click reload button in browser and also F5 and in both cases stuff that I wrote before didn't disappear.
Anyway, I think this script is going to be useful, probably significant part of users faced such thing at least once.

Well, to me, sometimes it happens, but not always. Maybe because you write long, or maybe this only happens to quoted replies?
I'm using Chrome; I've never tried it on Firefox, so the problem could be with the browser. I tried multiple times just now while writing this post, but it does not save; only the quotes remain intact.

So the script is going to be useful, I believe, to those who are having the same issue as mine.

░░░░▄▄████████████▄
▄████████████████▀
▄████████████████▀▄█▄
▄██████▀▀░░▄███▀▄████▄
▄██████▀░░░▄███▀▀██████▄
██████▀░░▄████▄░░░▀██████
██████░░▀▀▀▀▄▄▄▄░░██████
██████▄░░░▀████▀░░▄██████
▀██████▄▄███▀░░░▄██████▀
▀████▀▄████░░▄▄███████▀
▀█▀▄████████████████▀
▄████████████████▀
▀████████████▀▀░░░░
 
 CCECASH 
alegotardo
Legendary
*
Offline

Activity: 3248
Merit: 1774


☢️ alegotardo™


View Profile WWW
Today at 12:46:53 AM
 #13

This solution is incredible!

I would like to know if.... your script could also work to other sites outside Bitcointalk?
I’ve already had problems like this with forms in others websites... sometimes I lose the information even when some kind of server error occurs, when I return to the form everything that I had typed is lost (yes... this is a programming problem of website, but the users are the ones who suffer the consequences).

When this happens to me, sometimes the back button restores everything.

It does not work when you accidentally click Reload. Everything you wrote, including the subject title, is completely gone, and the back button cannot save them.

I believe that something like this script of OP should be a native feature of browser, whether going back to the page or reloading it.

Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!