mods.de Forum - Lesezeichen

Verbessert die Darstellung und Verwendung der Lesezeichenfunktion

当前为 2015-11-03 提交的版本,查看 最新版本

// ==UserScript==
// @name          mods.de Forum - Lesezeichen
// @description   Verbessert die Darstellung und Verwendung der Lesezeichenfunktion
// @author        TheRealHawk
// @namespace     http://forum.mods.de
// @match         http://forum.mods.de/bb/
// @match         http://forum.mods.de/bb/index.php
// @match         http://forum.mods.de/bb/thread.php*
// @icon          https://i.imgur.com/wwA18B8.png
// @version       1.3
// @grant         GM_addStyle
// @grant         GM_getResourceURL
// @grant         GM_getResourceText
// @require       https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js
// @require       https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/jquery-ui.min.js
// @require       https://greasyfork.org/scripts/5844-tablesorter/code/TableSorter.js
// @resource      jQueryUICSS https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/themes/eggplant/jquery-ui.min.css
// @resource      ui-bg_flat_0_eeeeee_40x100.png https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/themes/eggplant/images/ui-bg_flat_0_eeeeee_40x100.png
// @resource      ui-bg_gloss-wave_30_3d3644_500x100.png https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/themes/eggplant/images/ui-bg_gloss-wave_30_3d3644_500x100.png
// @resource      ui-bg_highlight-soft_100_dcd9de_1x100.png https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/themes/eggplant/images/ui-bg_highlight-soft_100_dcd9de_1x100.png
// @resource      ui-bg_highlight-soft_100_eae6ea_1x100.png https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/themes/eggplant/images/ui-bg_highlight-soft_100_eae6ea_1x100.png
// @resource      ui-bg_highlight-soft_25_30273a_1x100.png https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/themes/eggplant/images/ui-bg_highlight-soft_25_30273a_1x100.png
// @resource      ui-bg_highlight-soft_45_5f5964_1x100.png https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/themes/eggplant/images/ui-bg_highlight-soft_45_5f5964_1x100.png
// @resource      ui-icons_454545_256x240.png https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/themes/eggplant/images/ui-icons_454545_256x240.png
// @resource      ui-icons_734d99_256x240.png https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/themes/eggplant/images/ui-icons_734d99_256x240.png
// @resource      ui-icons_8d78a5_256x240.png https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/themes/eggplant/images/ui-icons_8d78a5_256x240.png
// @resource      ui-icons_ffffff_256x240.png https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/themes/eggplant/images/ui-icons_ffffff_256x240.png
// ==/UserScript==

(function(){
    var resources = {
        'ui-bg_flat_0_eeeeee_40x100.png': GM_getResourceURL('ui-bg_flat_0_eeeeee_40x100.png'),
        'ui-bg_gloss-wave_30_3d3644_500x100.png': GM_getResourceURL('ui-bg_gloss-wave_30_3d3644_500x100.png'),
        'ui-bg_highlight-soft_100_dcd9de_1x100.png': GM_getResourceURL('ui-bg_highlight-soft_100_dcd9de_1x100.png'),
        'ui-bg_highlight-soft_100_eae6ea_1x100.png': GM_getResourceURL('ui-bg_highlight-soft_100_eae6ea_1x100.png'),
        'ui-bg_highlight-soft_25_30273a_1x100.png': GM_getResourceURL('ui-bg_highlight-soft_25_30273a_1x100.png'),
        'ui-bg_highlight-soft_45_5f5964_1x100.png': GM_getResourceURL('ui-bg_highlight-soft_45_5f5964_1x100.png'),
        'ui-icons_454545_256x240.png': GM_getResourceURL('ui-icons_454545_256x240.png'),
        'ui-icons_734d99_256x240.png': GM_getResourceURL('ui-icons_734d99_256x240.png'),
        'ui-icons_8d78a5_256x240.png': GM_getResourceURL('ui-icons_8d78a5_256x240.png'),
        'ui-icons_ffffff_256x240.png': GM_getResourceURL('ui-icons_ffffff_256x240.png')
    };
    var jQueryUICSS = GM_getResourceText('jQueryUICSS');
    $.each(resources, function(resourceName, resourceUrl) {
        jQueryUICSS = jQueryUICSS.replace('images/' + resourceName, resourceUrl);
    });
    GM_addStyle(jQueryUICSS);
})();

unsafeWindow.setBookmarkNew = function(pid, token){
    async_get(
    'async/set-bookmark.php?PID='+pid+'&token='+token, null,
    function(xml){
        var message = '';
        switch(parseInt(xml.responseText)){
            case 1: message = 'Lesezeichen gesetzt.'; break;
            case 2: message = 'Du hast bereits zu viele Lesezeichen!'; break;
            default: message = 'Unbekannter Fehler:<br>' + xml.responseText; break;
        }
        $('body').append('<div id="overlayDialog">' + message + '</div>');
        $('#overlayDialog').dialog({
            draggable: false,
            resizable: false,
            modal:     true,
            title:     'Lesezeichen',
            buttons: {
                Ok: function(){
                    $(this).dialog('close');
                }
            },
            position: {my: "right top", at: "right top", of: window}
        });
    });
    return;
}

$('a[href^="javascript:setBookmark"]').each(function(){
    this.href = this.href.replace(/^javascript:setBookmark/, "javascript:setBookmarkNew");
});

function stripeRows() {
    $('#bookmarklist > table > tbody > tr').removeClass('color3b')
        .filter(':even').addClass('color3b');
}

if ($('#bookmarklist').length){
    $('#bookmarklist > table').prepend('<thead><tr class="l"><th></th><th>Forum</th><th>Thread</th><th>#Posts</th><th></th><th></th><th style="display:none"></th></tr></thead>');
    $('#bookmarklist > table > tbody > tr').each(function(){
        if ($('td:nth-child(4)', this).text().indexOf('neu') != -1){
            $(this).append('<td style="display:none">0</td>');
        } else if ($('td:nth-child(3)', this).has('del').length){
            $(this).append('<td style="display:none">2</td>');
        } else {
            $(this).append('<td style="display:none">1</td>');
        }
    });
    $('#bookmarklist > table').tablesorter({
        sortList: [[6,0],[1,1],[2,0]],
        sortForce: [[6,0]],
        headers: {
            0: {sorter: false},
            4: {sorter: false},
            5: {sorter: false},
            6: {sorter: false}
        }
    });
    $('#bookmarklist > table').bind('sortEnd', stripeRows);
    $('#bookmarklist > table').css('border-collapse', 'collapse');
    $('#bookmarklist > table > tbody > tr').css('border-bottom', '2px solid transparent');
    $('#bookmarklist > table > tbody > tr > td > a').css('color', '#ccc');
    stripeRows();
}