jandan comment refresh

为煎蛋吐槽增加刷新按钮,不用手动刷新页面就可以看到最新的吐槽内容。

当前为 2018-02-27 提交的版本,查看 最新版本

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         jandan comment refresh
// @namespace    [email protected]
// @version      0.1.1
// @description  为煎蛋吐槽增加刷新按钮,不用手动刷新页面就可以看到最新的吐槽内容。
// @author       You
// @match        http*://jandan.net/pic*
// @match        http*://jandan.net/ooxx*
// @match        http*://jandan.net/duan*
// @match        http*://jandan.net/qa*
// @match        http*://jandan.net/top
// @match        http*://jandan.net/drawings*
// @match        http*://jandan.net/pond*
// @match        http*://jandan.net/zhoubian*
// @grant        none
// ==/UserScript==

(function () {
    'use strict';

    if (window.top != window.self) return;
    window.refreshComment = function (node) {
        node = node.parent().parent('div');
        var c = node.attr('id').split('-')[2];
        node.children('.tucao-hot, .tucao-list, .jandan-tucao-more, .jandan-tucao-close, .tucao-form, #tucao-gg').remove().empty();
        var a = $('<div class="tucao-tmp">数据加载中....biubiubiu....</div>');
        node.append(a);
        $.ajax({
            url: "/tucao/" + c,
            method: "GET",
            dataType: "json",
            success: function (f) {
                node.children('.tucao-tmp').remove().empty();
                if (f.code != 0) {
                    alert(f.msg);
                    return;
                }
                if (f.hot_tucao.length) {
                    tucao_show_hot(node, f.hot_tucao);
                }
                tucao_show_list(node, f.tucao);
                if (f.has_next_page) {
                    tucao_show_more_btn(node, c);
                }
                tucao_show_close_btn(node, c);
                tucao_show_form(node, c);
            },
            error: function (e) {
                a.html("hmm....something wrong...");
            }
        });
    };
    $(document).bind('DOMNodeInserted', function (e) {
        var element = e.target;
        element = $(element);
        if (element.hasClass('tucao-form')) {
            var node = element.parent('div');
            if(node.find('.tucao-refresh').length) return;
            node.prepend('<div class="tucao-refresh" style="text-align: right;"><span style="cursor: pointer;" onclick="refreshComment($(this))">刷新</span></div>');
        }
    });
})();