<commit_before>// ==UserScript==
// @name         ProgrammersForumQuickQuote
// @namespace    http://programmersforum.ru/
// @version      0.2
// @description  adds a button to quote selected text, also changes the reply/quote button to not reload page
// @author       <NAME>
// @include      http://programmersforum.ru/*
// @include      http://www.programmersforum.ru/*
// @require      https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js
// @grant        GM_addStyle
// @downloadURL  https://github.com/AlexP11223/ProgForumRuUserscripts/raw/master/pf_quick_quote.user.js
// ==/UserScript==

(function() {
    'use strict';

    function getSelectedText() {
        return window.getSelection().toString();
    }

    function onPostClicked(e) {
        var selectedText = $.trim(getSelectedText());
        if (selectedText) {
            qqBtn.css({ top: (e.pageY + 10) + 'px', left: e.pageX + 'px'});
            qqBtn.show();

            qqBtn.delay(3000).fadeOut();

            var postContainer = $(this).closest('table');

            currPostId = postContainer.attr('id').replace('post', '');
            currAuthorName = postContainer.find('.bigusername').first().text();

            currSelectedText = selectedText;
        }
        else {
            qqBtn.hide();
        }
    }

    function appendText(text) {
        if (vB_Editor[QR_EditorID].get_editor_contents().length > 0) {
            text = '\n' + text;
        }
        vB_Editor[QR_EditorID].insert_text(text);
        vB_Editor[QR_EditorID].collapse_selection_end();
    }

    function appendQuote(text) {
        appendText('[QUOTE=' + currAuthorName + ';' + currPostId + ']' + text + '[/QUOTE]\n');
    }

    function quoteSelected() {
        appendQuote(currSelectedText);

        qqBtn.hide();
    }

    function quotePost(postQuoteUrl, progressIndicator) {
        progressIndicator.show();

        $.get(postQuoteUrl, function(response) {
                var html = $.parseHTML(response);

                var quote = $.trim($(html).find('#vB_Editor_001_textarea').text());

                if (quote) {
                    appendText(quote);
                }
            }).done(function() {
            progressIndicator.hide();
        });
    }

    GM_addStyle('.qq-btn { z-index: 999;' +
        'position: absolute;' +
        'border: 1px solid midnightblue;' +
        'padding: 3px;' +
        'font-weight: bold;' +
        'cursor: pointer;' +
        'background-color: lightyellow; }');

    $('<div id="quick_quote_btn" class="smallfont qq-btn" style="display:none;">Цитировать</div>').prependTo($('body'));

    var qqBtn = $('#quick_quote_btn');

    qqBtn.click(quoteSelected);

    qqBtn.hover(function() {
            qqBtn.stop(true, true);
        },
        function() {
            qqBtn.delay(3000).fadeOut();
        });
<commit_msg>fix global object access in Firefox<commit_after>// ==UserScript==
// @name         ProgrammersForumQuickQuote
// @namespace    http://programmersforum.ru/
// @version      0.3
// @description  adds a button to quote selected text, also changes the reply/quote button to not reload page
// @author       <NAME>
// @include      http://programmersforum.ru/*
// @include      http://www.programmersforum.ru/*
// @require      https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js
// @grant        none
// @downloadURL  https://github.com/AlexP11223/ProgForumRuUserscripts/raw/master/pf_quick_quote.user.js
// ==/UserScript==

// @grant must be none, otherwise cannot access vB_Editor in Firefox

(function() {
    'use strict';

    function addStyle(css) {
        var head = document.getElementsByTagName('head')[0];
        var style = document.createElement('style');
        style.type = 'text/css';
        style.innerHTML = css;
        head.appendChild(style);
    }

    function getSelectedText() {
        return window.getSelection().toString();
    }

    function onPostClicked(e) {
        var selectedText = $.trim(getSelectedText());
        if (selectedText) {
            qqBtn.css({ top: (e.pageY + 10) + 'px', left: e.pageX + 'px'});
            qqBtn.show();

            qqBtn.delay(3000).fadeOut();

            var postContainer = $(this).closest('table');

            currPostId = postContainer.attr('id').replace('post', '');
            currAuthorName = postContainer.find('.bigusername').first().text();

            currSelectedText = selectedText;
        }
        else {
            qqBtn.hide();
        }
    }

    function appendText(text) {
        if (vB_Editor[QR_EditorID].get_editor_contents().length > 0) {
            text = '\n' + text;
        }
        vB_Editor[QR_EditorID].insert_text(text);
        vB_Editor[QR_EditorID].collapse_selection_end();
    }

    function appendQuote(text) {
        appendText('[QUOTE=' + currAuthorName + ';' + currPostId + ']' + text + '[/QUOTE]\n');
    }

    function quoteSelected() {
        appendQuote(currSelectedText);

        qqBtn.hide();
    }

    function quotePost(postQuoteUrl, progressIndicator) {
        progressIndicator.show();

        $.get(postQuoteUrl, function(response) {
                var html = $.parseHTML(response);

                var quote = $.trim($(html).find('#vB_Editor_001_textarea').text());

                if (quote) {
                    appendText(quote);
                }
            }).done(function() {
            progressIndicator.hide();
        });
    }

    addStyle('.qq-btn { z-index: 999;' +
        'position: absolute;' +
        'border: 1px solid midnightblue;' +
        'padding: 3px;' +
        'font-weight: bold;' +
        'cursor: pointer;' +
        'background-color: lightyellow; }');

    $('<div id="quick_quote_btn" class="smallfont qq-btn" style="display:none;">Цитировать</div>').prependTo($('body'));

    var qqBtn = $('#quick_quote_btn');

    qqBtn.click(quoteSelected);

    qqBtn.hover(function() {
            qqBtn.stop(true, true);
        },
        function() {
            qqBtn.delay(3000).fadeOut();
        });

{'fraction_non_alphanumeric': 0.15505025539627615, 'fraction_numerical': 0.009721535673092767, 'mean_word_length': 2.208245243128964, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 11, 'https://': 4, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4702010', 'n_tokens_mistral': 1939, 'n_tokens_neox': 1794, 'n_words': 313}