去刷屏

lalala

当前为 2017-05-12 提交的版本,查看 最新版本

// ==UserScript==
// @name         去刷屏
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  lalala
// @author       miaomiao
// @match        http://bbs.jjwxc.net/board.php?board=*&type=*&page=*
// @match        http://bbs.jjwxc.net/showmsg.php?board=*&boardpagemsg=*&id=*
// @grant        none
// ==/UserScript==

(function() {
        'use strict';

        // Your code here...
        $("[id=topic]").each(function(index, element) {
                var text = $(element).text();
                var flag = text.length > 200 ? true: false;
                if (flag) {
                        $(element).html("");
                        $(element).append("<p>" + text.substring(0, 200) + "<span id='hide"+index+"' style='display:none'>" + text.substring(200) + "</span>" + "<a href='javascript:;' id='open"+index+"'>...显示全部</a></p>");
                }
                $("#open"+index).click(function() {
                        if (flag) {
                                $("#open"+index).text("...隐藏");
                                $("#hide"+index).show();
                                flag = false;
                        } else {
                                $("#open"+index).text("...显示全部");
                                $("#hide"+index).hide();
                                flag = true;
                        }
                });
        });
})();