Bold Reply

Bedre reply-funktion på bold.dk

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey, Greasemonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

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

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

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

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्क्रिप्ट व्यवस्थापक एक्स्टेंशन इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्क्रिप्ट व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्टाईल व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

// ==UserScript==
// @name        Bold Reply
// @namespace   http://quovadis.dk/
// @description Bedre reply-funktion på bold.dk
// @include     https://www.bold.dk/snak/index.php?action=reply&id=*
// @include     https://www.bold.dk/snak/index.php?action=thread&id=*
// @icon        https://www.bold.dk/favicon.ico
// @version     1.0.2
// ==/UserScript==

console.log('Bold Reply');

function bold_reply_main() {
    var url = document.location;
    console.log(url);
    if (/thread/.test(url)) {
        addAuthor();
    }
    if (/reply/.test(url)) {
        addQuote();
    }
}

function addAuthor() {
    $('a.tekst').each(function (idx) {
        var href = $(this).attr('href');
        if (/reply/.test(href)) {
            var author = $(this).parent().parent().find('a > b').html();
            console.log(author);
            $(this).attr('href', href + '&author=' + encodeURIComponent(author));
        }
    });
}

function getAuthor() {
    var author = '';
    try {
        author = decodeURIComponent(/author=(.*)$/.exec(document.location)[1]);
    }
    catch (e) {
        console.warn('No author found');
    }
    return author;
}

function addQuote() {
    var post = '[quote][b]' + getAuthor() + '[/b]: ';
    var quote = $('div.col1 > div').first().html();
    quote = quote.replace(/<strong>.*<\/strong>/, '');
    quote = quote.replace(/<(i|blockquote)>/gm, '[i]');
    quote = quote.replace(/<\/i>/gm, '[/i]');
    quote = quote.replace(/<\/blockquote>/gm, '[/i]\n\n');
    quote = quote.replace(/<b>/gm, '[b]');
    quote = quote.replace(/<\/b>/gm, '[/b]');
    quote = quote.replace(/<br>/gm, '\n');
    $('#post').val(post + quote.trim() + '[/quote]');
}

bold_reply_main();