// ==UserScript== // @name 豆瓣小组功能增强 // @version 0.1.1 // @license MIT // @namespace https://tcatche.github.io/ // @description 豆瓣小组展示功能增强:高亮包含指定关键字的帖子;隐藏包含指定关键字的帖子;去除标题省略号,展示全部文本;新标签页打开帖子 // @author tcatche // @match https://www.douban.com/group/* // @require https://code.jquery.com/jquery-3.3.1.min.js // @homepageURL https://github.com/tcatche/douban-group-enhance // @supportURL https://github.com/tcatche/douban-group-enhance/issues // @grant none // @downloadURL none // ==/UserScript== (function() { // 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 odlConfigString = localStorage.getItem('douban_group_filter_config'); try { const config = JSON.parse(configString || odlConfigString); return config; } catch (e) { return {}; } } // run user filters const runFilter = (config, self) => { const title = self.attr('title') || ''; const isInInclude = title => (config.include || []).filter(v => !!v).find(keyword => title.indexOf(keyword) >= 0); const isInDeclude = title => (config.declude || []).filter(v => !!v).find(keyword => title.indexOf(keyword) >= 0); const isTitleInInclude = isInInclude(title); const isTitleInDeclude = isInDeclude(title); if (isTitleInInclude && !isTitleInDeclude) { self.css({background: 'green', color: '#fff'}); } if (isInDeclude(title)) { self.parents('tr').hide(); } } const runOpenInNewTab = (config, self) => { if (config.openInNewTab) { self.attr('target', '_blank'); } } const runShowFullTitle = (config, self) => { if (config.showFullTitle) { const title = self.attr('title') || self.text(); self.text(title); } } const runEnhancer = config => { $('.topics tr .td-subject a, .title a').each(function() { const $this = $(this); runFilter(config, $this); runOpenInNewTab(config, $this); runShowFullTitle(config, $this); }); } // init config dom let configDivHtml = `