Thread Post Drafts

Save drafts of posts

K instalaci tototo skriptu si budete muset nainstalovat rozšíření jako Tampermonkey, Greasemonkey nebo Violentmonkey.

You will need to install an extension such as Tampermonkey to install this script.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Userscripts.

You will need to install an extension such as Tampermonkey to install this script.

K instalaci tohoto skriptu si budete muset nainstalovat manažer uživatelských skriptů.

(Už mám manažer uživatelských skriptů, nechte mě ho nainstalovat!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(Už mám manažer uživatelských stylů, nechte mě ho nainstalovat!)

// ==UserScript==
// @name         Thread Post Drafts
// @namespace    pxgamer
// @version      0.2
// @description  Save drafts of posts
// @author       pxgamer
// @include      *kat.cr/community/update/*/
// @grant        GM_setValue
// @grant        GM_getValue
// ==/UserScript==

(function() {
    'use strict';

    var threadId    = window.location.href.split('/')[5];
    var fieldArea   = $('#bbcode');
    var dataPreview = $('span.ka.ka-preview.bbedit-preview');

    $('.bbedit-toolbar').css('width', '500px');

    dataPreview.after(' <span title="Save Draft" class="ka saveDraftPX"><img src="https://pximg.xyz/images/b0d12ae13df1b376ac6557c488fb50f4.png" style="padding: 0 0 0px 2px; height: 18px; width: 18px;" /></span> <span title="Open Draft" class="ka openDraftPX"><img src="https://pximg.xyz/images/cd7c008c14979811583db3afc7b83fed.png" style="padding: 0 0 0px 2px; height: 18px; width: 18px;" /></span>');

    $('.saveDraftPX').on('click', function() {
        GM_setValue('thread_' + threadId, fieldArea.val());
    });

    $('.openDraftPX').on('click', function() {
        var saved = GM_getValue('thread_' + threadId, '');
        if (saved === '') {
            alert('No Drafts Saved for this Thread');
        }
        else {
            fieldArea.val(saved);
        }
    });
})();