// ==UserScript== // @name 豆瓣小组功能增强 // @version 0.2.0.1 // @license MIT // @namespace https://tcatche.github.io/ // @description 豆瓣小组展示功能增强:高亮包含指定关键字的帖子;隐藏包含指定关键字的帖子;去除标题省略号,展示全部文本;新标签页打开帖子;展示是否是楼主的标识;展示楼层号;淡化已读帖子标题;增加帖子内内容跳转 // @author tcatche // @match https://www.douban.com/group/* // @homepageURL https://github.com/tcatche/douban-group-enhance // @supportURL https://github.com/tcatche/douban-group-enhance/issues // @grant none // @downloadURL none // ==/UserScript== (function() { const enhancer = () => { // save user config const saveConfig = config => { const configString = JSON.stringify(config); localStorage.setItem('douban_group_enhance_config', configString); } // load user config const getConfig = () => { const configString = localStorage.getItem('douban_group_enhance_config'); const oldConfigString = localStorage.getItem('douban_group_filter_config'); try { const config = JSON.parse(configString || oldConfigString); return config; } catch (e) { return {}; } } // run user filters const runFilter = (config, self) => { const title = self.attr('title') || ''; const isInInclude = title => (config.include || []).find(keyword => title.indexOf(keyword) >= 0); const isInDeclude = title => (config.declude || []).find(keyword => title.indexOf(keyword) >= 0); const isTitleInInclude = isInInclude(title); const isTitleInDeclude = isInDeclude(title); if (isTitleInInclude && !isTitleInDeclude) { self.addClass('douban_group_enhance_highlight'); } if (isInDeclude(title)) { self.parents('tr').hide(); } } // open in new tab const runOpenInNewTab = (config, self) => { if (config.openInNewTab) { self.attr('target', '_blank'); } } // show full title without cliped! const runShowFullTitle = (config, self) => { if (config.showFullTitle) { const title = self.attr('title') || self.text(); self.text(title); } } // run fade visited topic const runFadeVisitedTitle = config => { if (config.fadeVisited) { if ($('#fadeVisitedStyle').length === 0) { $('body').append(` `); } } else { $('#fadeVisitedStyle').remove(); } } // show reply number const runShowReplyNumber = (options, self, index) => { if (options.config.showReplyNumber) { const replyHead = self.find('h4')[0]; const isInserted = $(replyHead).find('.douban_group_enhance_replay_number').length > 0; if (!isInserted) { const start = +(options.params.start || 0); const replayNumber = start + 1 + index; $(replyHead).append(`${replayNumber}楼`); } } else { $('.douban_group_enhance_replay_number').remove(); } } // show if is topic owner const runShowOwnerTag = (options, self) => { if (options.config.showOwnerTag) { const replyHead = self.find('h4')[0]; const isInserted = $(replyHead).find('.douban_group_enhance_owner_tag').length > 0; if (!isInserted) { const replyName = self.find('h4 a').text().trim(); if (replyName === options.topicUser) { $(replyHead).append('楼主'); } } } else { $('.douban_group_enhance_owner_tag').remove(); } } // add jump to top, comments and pager button const runAddJumptoButton = options => { if (options.config.jumpTo) { const isAdded = $('#douban_group_enhance_jump').length > 0; if (!isAdded) { $(document.body).append(`