Yet Another Weibo Filter

新浪微博根据关键词、作者、话题、来源等过滤微博;修改版面。 新浪微博根據關鍵字、作者、話題、來源等篩選微博;修改版面。 filter Sina Weibo by keywords, original, topic, source, etc.; modify layout

当前为 2014-08-07 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Yet Another Weibo Filter
  3. // @namespace https://github.com/tiansh
  4. // @description 新浪微博根据关键词、作者、话题、来源等过滤微博;修改版面。 新浪微博根據關鍵字、作者、話題、來源等篩選微博;修改版面。 filter Sina Weibo by keywords, original, topic, source, etc.; modify layout
  5. // @include http://weibo.com/*
  6. // @include http://www.weibo.com/*
  7. // @version 0.3.43 beta
  8. // @author 田生
  9. // @copyright 田生; The MIT License
  10. // @license The MIT License (MIT); http://opensource.org/licenses/MIT
  11. // @grant GM_xmlhttpRequest
  12. // @grant GM_setValue
  13. // @grant GM_getValue
  14. // @grant GM_addStyle
  15. // @grant GM_registerMenuCommand
  16. // @grant GM_info
  17. // @grant unsafeWindow
  18. // @run-at document-start
  19. // ==/UserScript==
  20.  
  21. // 图片
  22. var images = {
  23. 'filter': 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAMAAAAoLQ9TAAAABGdBTUEAALGPC/xhBQAAAAFzUkdCAK7OHOkAAAFEUExURUxpcZ6eno6OjpmZmf////v7+/j4+Pr6+vr6+uzs7MvLy8rKyuzs7Ly8vLy8vO7u7r29vb29ve7u7unp6by8vOrq6ufn5+/v776+vry8vO3t7ejo6Ojo6Ovr6+/v7729ve7u7ry8vO/v7+vr6+jo6L6+vu7u7ry8vO/v7+rq6ujo6L6+vu3t7e/v77e3t+vr6+jo6Jubm5qampqamp+fn7m5uezs7MXFxe7u7p2dnZubm5+fn5ycnOzs7L6+vsDAwMLCwsHBwevr6/Ly8vr6+sPDw+3t7e/v78TExMHBwcnJycXFxff39+np6e7u7vPz8/f39/j4+O/v7/T09Ovr6/////Dw8PT09P///9zc3Pn5+fv7+////+3t7f///9ra2v///8DAwOPj49PT0////8LCwtHR0b+/v+Pj48bGxsHBwcfHx0ifhqUAAABsdFJOUwA/Skoauru8u8K7u40sLY8yMYeULoqRijIxjIiNkI42jTWQko86nDaeoJ08sLRKuLQ1Nj8yUL2twEc9Nzq6op6lqbbGn6K/wKymsqmExsO6foDKuMV+wchsm3qmF8l6l2ZWC7oWtrpSCLq2ugo9naEAAAClSURBVBjTY2DAANGsbOzsHEDAzs7G6gIUCI9Ny8rm4ubmykxNDnIGCniFxKczMjEzMzEmRvqaAwUsvYMTMkB6kyL8HYxBDCuPsLgUBgaWUD9HI4ixNp6cUTEsgZx2hjCLrF3dA3zc7E0QVptaONma6SG5RVvXQF9HHUlAVUNLU00RSUBeSUVZQRJJQEJORlaKD0lAQFxaVEgESUCQX0yYh5cBKwAASvgW88X18swAAAAASUVORK5CYII=',
  24. };
  25.  
  26. // 多行字符串
  27. var funcStr = function (f) {
  28. var s = f.toString().split(/\r\n|\r|\n/g).slice(1, -1).join('\n');
  29. return s;
  30. };
  31.  
  32. // 快速创建一段文档元素
  33. var cewih = function (tag, inner) {
  34. var d = document.createElement(tag);
  35. d.innerHTML = inner;
  36. return d;
  37. };
  38.  
  39. // 文本常量
  40. // 请以简体中文为原文,参考这些资料翻译
  41. // http://zh.wikipedia.org/wiki/Template:CGroup/IT
  42. // http://www.microsoft.com/Language/zh-cn/Search.aspx
  43. var text = {
  44. // 基本按钮
  45. 'okButtonTitle': { 'zh-cn': '确定', 'zh-hk': '確定', 'zh-tw': '確定', 'en': 'Confirm' },
  46. 'cancelButtonTitle': { 'zh-cn': '取消', 'zh-hk': '取消', 'zh-tw': '取消', 'en': 'Cancel' },
  47. 'closeButtonTitle': { 'zh-cn': '关闭', 'zh-hk': '關閉', 'zh-tw': '關閉', 'en': 'Close' },
  48. 'configStringsAdd': { 'zh-cn': '添加', 'zh-hk': '新增', 'zh-tw': '新增', 'en': 'Add' },
  49. 'configUsersAdd': { 'zh-cn': '添加', 'zh-hk': '新增', 'zh-tw': '新增', 'en': 'Add' },
  50. 'foldedWeiboText': {
  51. 'zh-cn': '"来自 @" attr(yawf-author) " 的一条微博被折叠,请点击查看"',
  52. 'zh-hk': '"來自 @" attr(yawf-author) " 的一條微博被折疊,請點擊查看"',
  53. 'zh-tw': '"來自 @" attr(yawf-author) " 的一條微博被折疊,請點擊查看"',
  54. 'en': '"A Weibo from @" attr(yawf-author) " was folded, click to view."'
  55. },
  56. 'disabledKey': { 'zh-cn': '(已禁用)', 'zh-hk': '(已停用)', 'zh-tw': '(已停用)', 'en': '(Disabled)' },
  57. // 设置框
  58. 'filter': { 'zh-cn': '过滤器', 'zh-hk': '篩選器', 'zh-tw': '篩選器', 'en': 'Filter' },
  59. 'configDialogTitle': { 'zh-cn': '过滤器设置', 'zh-hk': '篩選器設定', 'zh-tw': '篩選器設定', 'en': 'Filter Settings' },
  60. 'whitelistFilterDesc': { 'zh-cn': '总是显示{{{typed}}}', 'zh-hk': '總是顯示{{{typed}}}', 'zh-tw': '總是顯示{{{typed}}}', 'en': 'Always show {{{typed}}}' },
  61. 'blacklistFilterDesc': { 'zh-cn': '隐藏{{{typed}}}', 'zh-hk': '隱藏{{{typed}}}', 'zh-tw': '隱藏{{{typed}}}', 'en': 'Hide {{{typed}}}' },
  62. 'foldlistFilterDesc': { 'zh-cn': '折叠{{{typed}}}', 'zh-hk': '折疊{{{typed}}}', 'zh-tw': '折疊{{{typed}}}', 'en': 'Fold {{{typed}}}' },
  63. 'whitelistActionDesc': { 'zh-cn': '显示', 'zh-hk': '顯示', 'zh-tw': '顯示', 'en': 'Show' },
  64. 'blacklistActionDesc': { 'zh-cn': '隐藏', 'zh-hk': '隱藏', 'zh-tw': '隱藏', 'en': 'Hide' },
  65. 'foldlistActionDesc': { 'zh-cn': '折叠', 'zh-hk': '折疊', 'zh-tw': '折疊', 'en': 'Fold' },
  66. // 关键词
  67. 'keywordFilterGroupTitle': { 'zh-cn': '内容', 'zh-hk': '內容', 'zh-tw': '內容', 'en': 'Content' },
  68. 'keywordFilterDesc': { 'zh-cn': '关键词', 'zh-hk': '關鍵字', 'zh-tw': '關鍵字', 'en': 'Keyword' },
  69. 'keywordFilterDetails': { 'zh-cn': '包含以下关键词的微博', 'zh-hk': '包含以下關鍵字的微博', 'zh-tw': '包含以下關鍵字的微博', 'en': 'Weibo with these keywords' },
  70. 'keywordFilterFast': { 'zh-cn': '包含关键词', 'zh-hk': '包含關鍵字', 'zh-tw': '包含關鍵字', 'en': 'Weibo contains keyword ' },
  71. 'keywordFilterFastInput': { 'zh-cn': '“{{text}}”', 'zh-hk': '「{{text}}」', 'zh-tw': '「{{text}}」', 'en': '"{{text}}"' },
  72. // 正则表达式
  73. 'regexpFilterGroupTitle': { 'zh-cn': '正则', 'zh-hk': '正則', 'zh-tw': '正規', 'en': 'Regexp' },
  74. 'regexpFilterDesc': { 'zh-cn': '正则式', 'zh-hk': '正則式', 'zh-tw': '正規式', 'en': 'Regexp' },
  75. 'regexpFilterDetails': { 'zh-cn': '匹配以下正则表达式的微博', 'zh-hk': '匹配以下正則表達式的微博', 'zh-tw': '匹配以下正規表示式的微博', 'en': 'Weibo matches these regular expressions' },
  76. 'regexpFilterFast': { 'zh-cn': '匹配正则式', 'zh-hk': '匹配正則式', 'zh-tw': '匹配正規式', 'en': 'Weibo matches regexp ' },
  77. 'regexpFilterFastInput': { 'zh-cn': '/{{text}}/', 'zh-hk': '/{{text}}/', 'zh-tw': '/{{text}}/', 'en': '/{{text}}/' },
  78. 'regexpFilterRemark': {
  79. 'zh-cn': '正则表达式的过滤方式提供了基于微博内容的高级过滤方式,如果只是需要简单地关键词过滤请使用内容标签页的关键词以获得更好的效率。正则表达式书写时不需要对“/”字符转义。',
  80. 'zh-hk': '正則表達式的過濾方式提供了基於微博內容的高級過濾方式,如果只是需要簡單地關鍵字過濾請使用內容標籤頁的關鍵字以獲得更好的效率。正則表達式書寫時不需要對「/」字符轉義。',
  81. 'zh-tw': '正規表示式的過濾方式提供了基於微博內容的高級過濾方式,如果只是需要簡單地關鍵字過濾請使用內容標籤頁的關鍵字以獲得更好的效率。正規表示式書寫時不需要對「/」字符轉義。',
  82. 'en': 'Regular expression provide advanced filter settings based on content. You may set keywords in Content tab for better performance. You do not need to escape "/" in your regexp.'
  83. },
  84. 'regexpBadFormedTitle': { 'zh-cn': '非法的正则表达式', 'zh-hk': '不合法的正則表達式', 'zh-tw': '不合法的正規表示式', 'en': 'Illegal Regexp' },
  85. 'regexpBadFormed': {
  86. 'zh-cn': '您输入的/{{regexp}}/不能被正确地解析为正则表达式,请检查您的输入。如需关键词屏蔽请到内容标签页设置。',
  87. 'zh-hk': '您输入的/{{regexp}}/不能被正确地解析为正则表达式,请检查您的输入。如需关键词屏蔽请到内容标签页面设置。',
  88. 'zh-tw': '您輸入的/{{regexp}}/不能被正確地解析為正規表示式,請檢查您的輸入。如需關鍵詞屏蔽請到內容標籤頁面設置。',
  89. 'en': 'Cannot parse /{{regexp}}/ as regexp. Please check your input. You may hide Weibo by keywords in Content tab page.'
  90. },
  91. // 帐号
  92. 'accountFilterGroupTitle': { 'zh-cn': '帐号', 'zh-hk': '帳號', 'zh-tw': '帳號', 'en': 'Account' },
  93. 'accountFilterDesc': { 'zh-cn': '帐号', 'zh-hk': '帳號', 'zh-tw': '帳號', 'en': 'Account' },
  94. 'accountFilterDetails': { 'zh-cn': '来自以下帐号的微博', 'zh-hk': '來自以下帳號的微博', 'zh-tw': '來自以下帳號的微博', 'en': 'Weibo from these accounts' },
  95. 'accountFilterFast': { 'zh-cn': '作者是“@{{name}}”的微博', 'zh-hk': '作者是「@{{name}}」的微博', 'zh-tw': '作者是「@{{name}}」的微博', 'en': 'Weibo from "@{{name}}"', },
  96. 'accountFilterRemark': {
  97. 'zh-cn': '推荐您到<a target="_blank" href="http://account.weibo.com/set/privacy#open=privacy_feeduser">隐私设置 - 屏蔽账号</a>屏蔽您关注了但不想在首页看到的账号。',
  98. 'zh-hk': '推薦您到<a target="_blank" href="http://account.weibo.com/set/privacy#open=privacy_feeduser">隱私設置 - 屏蔽帐号</a>封鎖您關注了但不想在首頁看到的帳號。',
  99. 'zh-tw': '推薦您到<a target="_blank" href="http://account.weibo.com/set/privacy#open=privacy_feeduser">隱私設置 - 屏蔽帐号</a>封鎖您關注了但不想在首頁看到的帳號。',
  100. 'en': 'You can block Weibo from accounts you followed in the page <a target="_blank" href="http://account.weibo.com/set/privacy#open=privacy_feeduser">Privacy - Block account</a>.'
  101. },
  102. 'accountNotExistErrorTitle': { 'zh-cn': '帐号不存在', 'zh-hk': '帳號不存在', 'zh-tw': '帳號不存在', 'en': 'Account does not exist' },
  103. 'accountNotExistError': { 'zh-cn': '不存在名为{{name}}的账号', 'zh-hk': '不存在名為{{name}}的賬號', 'zh-tw': '不存在名為{{name}}的賬號', 'en': 'Account named {{name}} does not exist' },
  104. // 原创
  105. 'originalFilterGroupTitle': { 'zh-cn': '原创', 'zh-hk': '原創', 'zh-tw': '原創', 'en': 'Original' },
  106. 'originalFilterDesc': { 'zh-cn': '帐号', 'zh-hk': '帳號', 'zh-tw': '帳號', 'en': 'Account' },
  107. 'originalFilterDetails': { 'zh-cn': '原创是以下账号的微博', 'zh-hk': '原創是以下帳號的微博', 'zh-tw': '原創是以下帳號的微博', 'en': 'Hide Weibo orginal from these accounts' },
  108. 'originalFilterFast': { 'zh-cn': '原创是“@{{name}}”的微博', 'zh-hk': '原創是「@{{name}}」的微博', 'zh-tw': '原創是「@{{name}}」的微博', 'en': 'Weibo original from "@{{name}}"' },
  109. // 提到
  110. 'mentionFilterGroupTitle': { 'zh-cn': '提到', 'zh-hk': '提到', 'zh-tw': '提到', 'en': 'Mention' },
  111. 'mentionFilterDesc': { 'zh-cn': '帐号', 'zh-hk': '帳號', 'zh-tw': '帳號', 'en': 'Account' },
  112. 'mentionFilterDetails': { 'zh-cn': '提到以下账号的微博', 'zh-hk': '提到以下帳號的微博', 'zh-tw': '提到以下帳號的微博', 'en': 'Weibo mentioned these accounts' },
  113. 'mentionFilterFast': { 'zh-cn': '提到了“@{{name}}”的微博', 'zh-hk': '提到了「@{{name}}」的微博', 'zh-tw': '提到了「@{{name}}」的微博', 'en': 'Weibo mentioned "@{{name}}"' },
  114. // 话题
  115. 'topicFilterGroupTitle': { 'zh-cn': '话题', 'zh-hk': '話題', 'zh-tw': '話題', 'en': 'Topic' },
  116. 'topicFilterDesc': { 'zh-cn': '话题', 'zh-hk': '話題', 'zh-tw': '話題', 'en': 'Topic' },
  117. 'topicFilterDetails': { 'zh-cn': '包含以下话题的微博', 'zh-hk': '包含以下話題的微博', 'zh-tw': '包含以下話題的微博', 'en': 'Weibo with these topics' },
  118. 'topicFilterFast': { 'zh-cn': '包含“#{{topic}}#”话题的微博', 'zh-hk': '包含「#{{topic}}#」話題的微博', 'zh-tw': '包含「#{{topic}}#」話題的微博', 'en': 'Weibo contains topic "#{{topic}}#"' },
  119. // 来源
  120. 'sourceFilterGroupTitle': { 'zh-cn': '来源', 'zh-hk': '來源', 'zh-tw': '來源', 'en': 'Source' },
  121. 'sourceFilterDesc': { 'zh-cn': '来自', 'zh-hk': '來自', 'zh-tw': '來自', 'en': 'Via' },
  122. 'sourceFilterDetails': { 'zh-cn': '以下来源的微博', 'zh-hk': '以下來源的微博', 'zh-tw': '以下來源的微博', 'en': 'Weibo from these sources' },
  123. 'sourceFilterFast': { 'zh-cn': '来自“{{source}}”的微博', 'zh-hk': '來自「{{source}}」的微博', 'zh-tw': '來自「{{source}}」的微博', 'en': 'Weibo via "{{source}}"' },
  124. 'sourceFilterWarningTitle': { 'zh-cn': '默认来源', 'zh-hk': '預設來源', 'zh-tw': '預設來源', 'en': 'Default Source' },
  125. 'sourceFilterWarning': { 'zh-cn': '不能添加默认来源', 'zh-hk': '不能新增預設來源', 'zh-tw': '不能新增預設來源', 'en': 'You cannot add default source' },
  126. // 超链接
  127. 'hyperlinkFilterGroupTitle': { 'zh-cn': '链接', 'zh-hk': '連結', 'zh-tw': '連結', 'en': 'Link' },
  128. 'hyperlinkFilterDesc': { 'zh-cn': '超链接', 'zh-hk': '超連結', 'zh-tw': '超連結', 'en': 'Hyperlink' },
  129. 'hyperlinkFilterDetails': { 'zh-cn': '包含指向以下网站的超链接的微博', 'zh-hk': '包含指向以下站點的超連結的微博', 'zh-tw': '包含指向以下站點的超連結的微博', 'en': 'Weibo with hyperlink to these website' },
  130. 'hyperlinkFilterFast': { 'zh-cn': '包含指向包含“{{host}}”地址链接的微博', 'zh-hk': '包含指向包含「{{host}}」位址連結的微博', 'zh-tw': '包含指向包含「{{host}}」位址連結的微博', 'en': 'Weibo contains hyperlink to "{{host}}"' },
  131. // 更多
  132. 'otherFilterGroupTitle': { 'zh-cn': '更多', 'zh-hk': '其他', 'zh-tw': '其他', 'en': 'More' },
  133. // 显示
  134. 'otherWhitelistTitle': { 'zh-cn': '显示以下内容(不计入白名单)', 'zh-hk': '顯示以下內容(不計入白名單)', 'zh-tw': '顯示以下內容(不計入白名單)', 'en': 'Show following content (not regard as whitelist)' },
  135. 'showMyWeiboDesc': { 'zh-cn': '自己的微博', 'zh-hk': '自己的微博', 'zh-tw': '自己的微博', 'en': 'Weibo by myself' },
  136. 'showMyOriginalDesc': { 'zh-cn': '自己微博的转发', 'zh-hk': '自己微博的轉發', 'zh-tw': '自己微博的轉發', 'en': 'Forward of my Weibo' },
  137. 'showMentionMeDesc': { 'zh-cn': '提到自己的微博', 'zh-hk': '提到自己的微博', 'zh-tw': '提到自己的微博', 'en': 'Weibo mentioned me' },
  138. // 隐藏
  139. 'otherBlacklistTitle': { 'zh-cn': '隐藏以下内容', 'zh-hk': '以下內容', 'zh-tw': '隱藏以下內容', 'en': 'Hide following content' },
  140. 'adfeedFilterDesc': { 'zh-cn': '推广微博', 'zh-hk': '推廣微博', 'zh-tw': '推廣微博', 'en': 'Ad Weibo' },
  141. 'recommandFeedDesc': { 'zh-cn': '推荐微博', 'zh-hk': '建議微博', 'zh-tw': '建議微博', 'en': 'Recommand Weibo' },
  142. 'fakeWeiboFilterDesc': { 'zh-cn': '混入微博列表的其它内容', 'zh-hk': '混入微博列表的其它內容', 'zh-tw': '混入微博列表的其它內容', 'en': 'Other contents in Weibo list' },
  143. 'deletedForwardFilterDesc': { 'zh-cn': '已删除微博的转发', 'zh-hk': '已刪除微博的轉發', 'zh-tw': '已刪除微博的轉發', 'en': 'Forward of deleted Weibo' },
  144. 'voteWeiboFilterDesc': { 'zh-cn': '投票微博', 'zh-hk': '投票微博', 'zh-tw': '投票微博', 'en': 'Vote weibo' },
  145. 'taobaoTianmaoWeibo': { 'zh-cn': '带有淘宝或天猫商品的微博', 'zh-hk': '帶有淘寶或天貓商品的微博', 'zh-tw': '帶有淘寶或天貓商品的微博', 'en': 'Weibo with Taobao / Tmall commodity' },
  146. // 刷屏与版聊
  147. 'otherSpammingTitle': { 'zh-cn': '刷屏与版聊', 'zh-hk': '洗版與版聊', 'zh-tw': '洗版與版聊', 'en': 'Spamming &amp; Chating' },
  148. 'sameAccountFilterDesc': { 'zh-cn': '相同作者的微博:|超过{{<number>}}条|时{{<action>}}', 'zh-hk': '相同作者的微博:|超過{{<number>}}條|時{{<action>}}', 'zh-tw': '相同作者的微博:|超過{{<number>}}條|時{{<action>}}', 'en': 'Weibo from same account: |{{<action>}} the part | which exceeds {{<number>}} Weibo' },
  149. 'sameForwardFilterDesc': { 'zh-cn': '相同微博的转发:|超过{{<number>}}条|时{{<action>}}', 'zh-hk': '相同微博的轉發:|超過{{<number>}}條|時{{<action>}}', 'zh-tw': '相同微博的轉發:|超過{{<number>}}條|時{{<action>}}', 'en': 'Forward from same Weibo: |{{<action>}} the part | which exceeds {{<number>}} Weibo' },
  150. // 分组浏览
  151. 'otherGroupTitle': { 'zh-cn': '分组浏览', 'zh-hk': '分組流覽', 'zh-tw': '分組流覽', 'en': 'Browse by Group' },
  152. 'accountByGroup': { 'zh-cn': '分组浏览时禁用按账号隐藏', 'zh-hk': '分組流覽時禁用按帳號隱藏', 'zh-tw': '分組流覽時禁用按帳號隱藏', 'en': 'Disable hide by account filter when browsing by group' },
  153. 'sameAccountByGroup': { 'zh-cn': '浏览分组时禁用相同作者数量限制', 'zh-hk': '流覽分組時禁用相同作者數量限制', 'zh-tw': '流覽分組時禁用相同作者數量限制', 'en': 'Disable hide too many Weibo from same account filter when browsing by group' },
  154. // 模块
  155. 'layoutFilterGroupTitle': { 'zh-cn': '模块', 'zh-hk': '模組', 'zh-tw': '模組', 'en': 'Module' },
  156. 'layoutFilterGroupDesc': { 'zh-cn': '隐藏以下模块', 'zh-hk': '隱藏以下模組', 'zh-tw': '隱藏以下模組', 'en': 'Hide following modules' },
  157. // 标识图标
  158. 'layoutHideIcon': { 'zh-cn': '标识/图标', 'zh-hk': '標誌/圖示', 'zh-tw': '標誌/圖示', 'en': 'Logo / Icon' },
  159. 'layoutHideIconLevel': { 'zh-cn': '等级', 'zh-hk': 'Level', 'zh-tw': '等級', 'en': 'Level' },
  160. 'layoutHideIconMember': { 'zh-cn': '微博会员', 'zh-hk': '微博會員', 'zh-tw': '微博會員', 'en': 'Weibo VIP / Member' },
  161. 'layoutHideIconApprove': { 'zh-cn': '个人认证', 'zh-hk': '個人認證', 'zh-tw': '個人認證', 'en': 'Personal Authentication / 個人認證' },
  162. 'layoutHideIconApproveCo': { 'zh-cn': '机构认证', 'zh-hk': '企業認證', 'zh-tw': '企業認證', 'en': 'Weibo Verification / 企業認證' },
  163. 'layoutHideIconClub': { 'zh-cn': '微博达人', 'zh-hk': '微博達人', 'zh-tw': '微博達人', 'en': 'Pioneer' },
  164. 'layoutHideIconVGirl': { 'zh-cn': '微博女郎', 'zh-hk': '微博女郎', 'zh-tw': '微博女郎', 'en': 'Weibo girl' },
  165. 'layoutHideIconTaobao': { 'zh-cn': '淘宝商户', 'zh-hk': '淘寶商戶', 'zh-tw': '淘寶商戶', 'en': 'Taobao Merchant' },
  166. 'layoutHideIconZongyika': { 'zh-cn': '我是综艺咖', 'zh-hk': '我是综艺咖'/* as is */, 'zh-tw': '我是综艺咖', 'en': '我是综艺咖 (Variety Wack)' },
  167. 'layoutHideIconYouji': { 'zh-cn': '邂逅有机', 'zh-hk': '邂逅有机'/* as is */, 'zh-tw': '邂逅有机', 'en': '邂逅有机 (Travel Notes)' },
  168. // 导航栏
  169. 'layoutHideNav': { 'zh-cn': '导航栏', 'zh-hk': '導覽列', 'zh-tw': '導覽列', 'en': 'Navigation Bar' },
  170. 'layoutHideNavMain': { 'zh-cn': '首页', 'zh-hk': '首頁', 'zh-tw': '首頁', 'en': 'Home' },
  171. 'layoutHideNavHot': { 'zh-cn': '热门', 'zh-hk': '熱門', 'zh-tw': '熱門', 'en': 'Hot' },
  172. 'layoutHideNavApp': { 'zh-cn': '应用', 'zh-hk': '應用', 'zh-tw': '應用', 'en': 'Apps' },
  173. 'layoutHideNavGame': { 'zh-cn': '游戏', 'zh-hk': '遊戲', 'zh-tw': '遊戲', 'en': 'Game' },
  174. 'layoutHideNavMember': { 'zh-cn': '会员菜单', 'zh-hk': '會員功能表', 'zh-tw': '會員功能表', 'en': 'VIP Menu' },
  175. // 左栏
  176. 'layoutHideLeft': { 'zh-cn': '左栏', 'zh-hk': '左欄', 'zh-tw': '左欄', 'en': 'Left Column' },
  177. 'layoutHideLeftToMe': { 'zh-cn': '发给我的', 'zh-hk': '發給我的', 'zh-tw': '發給我的', 'en': 'Send to me' },
  178. 'layoutHideLeftFriends': { 'zh-cn': '好友圈', 'zh-hk': '好友圈', 'zh-tw': '好友圈', 'en': 'Friends' },
  179. 'layoutHideLeftApp': { 'zh-cn': '应用', 'zh-hk': '应用', 'zh-tw': '应用'/* as is */, 'en': 'Apps' },
  180. // 中栏
  181. 'layoutHideMiddle': { 'zh-cn': '中栏', 'zh-hk': '中欄', 'zh-tw': '中欄', 'en': 'Middle Column' },
  182. 'layoutHideMiddleRecommendedTopic': { 'zh-cn': '热门微博(发布框上方)', 'zh-hk': '热门微博(發布框上方)', 'zh-tw': '热门微博(發布框上方)'/* as is */, 'en': '热门微博 (Hot Weibo), top of publisher' },
  183. 'layoutHideMiddleFeedRecommand': { 'zh-cn': '微博兴趣推荐(顶部)', 'zh-hk': '微博興趣推薦(頂部)', 'zh-tw': '微博興趣推薦(頂部)', 'en': 'Feed Recommand, top' },
  184. 'layoutHideMiddleMemberTip': { 'zh-cn': '开通会员提示(底部)', 'zh-hk': '開通會員提示(底部)', 'zh-tw': '開通會員提示(底部)', 'en': 'Tip of Join Weibo VIP, bottom' },
  185. // 右栏
  186. 'layoutHideRight': { 'zh-cn': '右栏', 'zh-hk': '右欄', 'zh-tw': '右欄', 'en': 'Right Column' },
  187. 'layoutHideRightTemplate': { 'zh-cn': '设置模板', 'zh-hk': '背景設定', 'zh-tw': '背景設定', 'en': 'Template Settings' },
  188. 'layoutHideRightInfo': { 'zh-cn': '头像', 'zh-hk': '頭像', 'zh-tw': '頭像', 'en': 'Avatar' },
  189. 'layoutHideRightTrial': { 'zh-cn': '登录赢会员', 'zh-hk': '登录赢会员', 'zh-tw': '登录赢会员'/* as is */, 'en': '登录赢会员 (Login for VIP Trial)' },
  190. 'layoutHideRightAtten': { 'zh-cn': '关注/粉丝/微博数', 'zh-hk': '關注/粉絲/微博數', 'zh-tw': '關注/粉絲/微博數', 'en': 'Numbers of Following/Followers/Weibo' },
  191. 'layoutHideRightInterest': { 'zh-cn': '可能感兴趣的人', 'zh-hk': '可能感興趣的人', 'zh-tw': '可能感興趣的人', 'en': 'You may know' },
  192. 'layoutHideRightHotTopic': { 'zh-cn': '热门话题', 'zh-hk': '熱門話題', 'zh-tw': '熱門話題', 'en': 'Hot Topic' },
  193. 'layoutHideRightMember': { 'zh-cn': '会员专区', 'zh-hk': '會員專區', 'zh-tw': '會員專區', 'en': 'Weibo VIP' },
  194. 'layoutHideRightWeibo': { 'zh-cn': '热门微博', 'zh-hk': '熱門微博', 'zh-tw': '熱門微博', 'en': 'Hot Weibo' },
  195. 'layoutHideRightLocation': { 'zh-cn': '地点推荐', 'zh-hk': '地點推薦', 'zh-tw': '地點推薦', 'en': 'Location' },
  196. 'layoutHideRightMusic': { 'zh-cn': ' 热门歌曲', 'zh-hk': '熱門歌曲', 'zh-tw': '熱門歌曲', 'en': 'Hot Music' },
  197. 'layoutHideRightMovie': { 'zh-cn': '最新电影', 'zh-hk': '最新電影', 'zh-tw': '最新電影', 'en': 'Hot Movie' },
  198. 'layoutHideRightBook': { 'zh-cn': '人气图书', 'zh-hk': '人氣圖書', 'zh-tw': '人氣圖書', 'en': 'Hot Book' },
  199. 'layoutHideRightNotice': { 'zh-cn': '公告栏', 'zh-hk': '公告欄', 'zh-tw': '公告欄', 'en': 'Bulletin Board' },
  200. // 微博内
  201. 'layoutHideWeibo': { 'zh-cn': '微博内', 'zh-hk': '微博內', 'zh-tw': '微博內', 'en': 'In Weibo' },
  202. 'layoutHideWeiboRecomFeed': { 'zh-cn': '精彩微博推荐', 'zh-hk': '精彩微博推薦', 'zh-tw': '精彩微博推薦', 'en': '精彩微博推荐 (Weibo you may interested in)' },
  203. 'layoutHideWeiboTopicCard': { 'zh-cn': '话题卡片', 'zh-hk': '話題卡片', 'zh-tw': '話題卡片', 'en': 'Topic Cards' },
  204. 'layoutHideWeiboFeedTip': { 'zh-cn': '评论框提示横幅', 'zh-hk': '評論框提示橫幅', 'zh-tw': '評論框提示橫幅', 'en': 'Tips for Comment' },
  205. 'layoutHideWeiboSonTitle': { 'zh-cn': '同源转发合并提示', 'zh-hk': '同源转发合并提示', 'zh-tw': '同源转发合并提示', 'en': '同源转发合并 (Merge forwards from same origin)' },
  206. 'layoutHideWeiboLocationCard': { 'zh-cn': '位置卡片', 'zh-hk': '位置卡片', 'zh-tw': '位置卡片', 'en': 'Location Cards' },
  207. 'layoutHideWeiboSource': { 'zh-cn': '来源', 'zh-hk': '來源', 'zh-tw': '來源', 'en': 'Source' },
  208. 'layoutHideWeiboReport': { 'zh-cn': '举报', 'zh-hk': '檢舉', 'zh-tw': '檢舉', 'en': 'Report' },
  209. 'layoutHideWeiboLike': { 'zh-cn': '赞', 'zh-hk': '讚', 'zh-tw': '讚', 'en': 'Like' },
  210. 'layoutHideWeiboForward': { 'zh-cn': '转发', 'zh-hk': '轉發', 'zh-tw': '轉發', 'en': 'Forward' },
  211. 'layoutHideWeiboFavourite': { 'zh-cn': '收藏', 'zh-hk': '收藏', 'zh-tw': '收藏', 'en': 'Favourite' },
  212. 'layoutHideWeiboBlockBySource': { 'zh-cn': '屏蔽来源', 'zh-hk': '屏蔽來源', 'zh-tw': '屏蔽來源', 'en': 'Block Source' },
  213. 'layoutHideWeiboBlockByKeyword': { 'zh-cn': '屏蔽关键词', 'zh-hk': '屏蔽關鍵詞', 'zh-tw': '屏蔽關鍵詞', 'en': 'Block Keywords' },
  214. // 个人主页
  215. 'layoutHidePerson': { 'zh-cn': '个人主页', 'zh-hk': '個人主頁', 'zh-tw': '個人主頁', 'en': 'Ones home page' },
  216. 'layoutHidePersonCover': { 'zh-cn': '封面图', 'zh-hk': '封面圖', 'zh-tw': '封面圖', 'en': 'Cover Picture' },
  217. 'layoutHidePersonTemplate': { 'zh-cn': '模板设置', 'zh-hk': '模板設置', 'zh-tw': '模板設置', 'en': 'Template Settings' },
  218. 'layoutHidePersonBadgeIcon': { 'zh-cn': '勋章', 'zh-hk': '勳章', 'zh-tw': '勳章', 'en': 'Badges' },
  219. 'layoutHidePersonStats': { 'zh-cn': '关注/粉丝/微博数', 'zh-hk': '關注/粉絲/微博數', 'zh-tw': '關注/粉絲/微博數', 'en': 'Numbers of Following/Followers/Weibo' },
  220. 'layoutHidePersonMyData': { 'zh-cn': '我的微博人气', 'zh-hk': '我的微博人气', 'zh-tw': '我的微博人气', 'en': '我的微博人气 (My Micro World)' },
  221. 'layoutHidePersonSuggestUser': { 'zh-cn': '可能感兴趣的人', 'zh-hk': '可能感兴趣的人', 'zh-tw': '可能感兴趣的人'/* as is */, 'en': 'Suggested' },
  222. 'layoutHidePersonGroup': { 'zh-cn': '推荐的人', 'zh-hk': '推荐的人', 'zh-tw': '推荐的人'/* as is */, 'en': '推荐的人 (Suggested Group)' },
  223. 'layoutHidePersonRelation': { 'zh-cn': '微关系', 'zh-hk': '微关系', 'zh-tw': '微关系'/* as is */, 'en': 'Relationship' },
  224. 'layoutHidePersonAlbum': { 'zh-cn': '图片', 'zh-hk': '相冊', 'zh-tw': '相冊', 'en': 'Album' },
  225. 'layoutHidePersonHotTopic': { 'zh-cn': '话题', 'zh-hk': '話題', 'zh-tw': '話題', 'en': 'Topic' },
  226. 'layoutHidePersonHotWeibo': { 'zh-cn': '热门微博', 'zh-hk': '熱門微博', 'zh-tw': '熱門微博', 'en': 'Hot Weibo' },
  227. // 杂项
  228. 'layoutHideOther': { 'zh-cn': '杂项', 'zh-hk': '雜項', 'zh-tw': '雜項', 'en': 'Others' },
  229. 'layoutHideOtherAds': { 'zh-cn': '广告', 'zh-hk': '廣告', 'zh-tw': '廣告', 'en': 'Advertisement' },
  230. 'layoutHideOtherFeedRecom': { 'zh-cn': '相关微博推荐', 'zh-hk': '相关推荐', 'zh-tw': '相关推荐', 'en': '相关推荐 (Related Weibo Suggestion)' },
  231. 'layoutHideOtherFooter': { 'zh-cn': '页面底部', 'zh-hk': '頁面底部', 'zh-tw': '頁面底部', 'en': 'Footer' },
  232. 'layoutHideOtherWbIm': { 'zh-cn': '微博桌面推荐(右下)', 'zh-hk': '微博桌面推薦(右下)', 'zh-tw': '微博桌面推薦(右下)', 'en': '微博桌面2014 (Desktop Weibo), bottom right' },
  233. 'layoutHideOtherTip': { 'zh-cn': '功能提示框', 'zh-hk': '功能提示框', 'zh-tw': '功能提示框', 'en': 'Function Tips' },
  234. // 工具
  235. 'toolFilterGroupTitle': { 'zh-cn': '工具', 'zh-hk': '工具', 'zh-tw': '工具', 'en': 'Tool' },
  236. // 边栏
  237. 'sideColumnToolsTitle': { 'zh-cn': '边栏', 'zh-hk': '邊欄', 'zh-tw': '邊欄', 'en': 'Side Column' },
  238. 'showAllGroupDesc': { 'zh-cn': '展开左栏分组', 'zh-hk': '展開左欄分組', 'zh-tw': '展開左欄分組', 'en': 'Unfold groups in left column' },
  239. 'showAllMsgNavDesc': { 'zh-cn': '展开左栏消息', 'zh-hk': '展開左欄消息', 'zh-tw': '展開左欄消息', 'en': 'Unfold news in left column' },
  240. 'mergeLeftRight': { 'zh-cn': '合并左右边栏|到{{<side>}}', 'zh-hk': '合併左右邊欄|到{{<side>}}', 'zh-tw': '合併左右邊欄|到{{<side>}}', 'en': 'Merge left &amp; right column | to {{<side>}}' },
  241. 'mergeLeftRightLeft': { 'zh-cn': '左侧', 'zh-hk': '左側', 'zh-tw': '左側', 'en': 'left side' },
  242. 'mergeLeftRightRight': { 'zh-cn': '右侧', 'zh-hk': '右側', 'zh-tw': '右側', 'en': 'right side' },
  243. 'fixedLeft': { 'zh-cn': '浮动左边栏|{{<items>}}', 'zh-hk': '浮動左邊欄|{{<items>}}', 'zh-tw': '浮動左邊欄|{{<items>}}', 'en': 'Float left column | {{<items>}}' },
  244. 'fixedLeftDefault': { 'zh-cn': '默认元素', 'zh-hk': '預設元素', 'zh-tw': '預設元素', 'en': 'default elements' },
  245. 'fixedLeftWhole': { 'zh-cn': '整个左栏', 'zh-hk': '整個左欄', 'zh-tw': '整個左欄', 'en': 'whole column' },
  246. // 微博
  247. 'weiboToolsTitle': { 'zh-cn': '微博', 'zh-hk': '微博', 'zh-tw': '微博', 'en': 'Weibo' },
  248. 'clearDefTopicDesc': { 'zh-cn': '清除发布框中的默认话题', 'zh-hk': '清除發布框中的預設話題', 'zh-tw': '清除發布框中的預設話題', 'en': 'Remove default topic in Publisher' },
  249. 'unwrapTextDesc': { 'zh-cn': '微博作者和正文同行', 'zh-hk': '微博作者和正文同行', 'zh-tw': '微博作者和正文同行', 'en': 'No line break after author' },
  250. 'personalRedirectWeibo': { 'zh-cn': '访问账号主页显示微博页面', 'zh-hk': '訪問帳號主頁顯示微博頁面', 'zh-tw': '訪問帳號主頁顯示微博頁面', 'en': 'Show Weibo page instead of personal mainpage by default' },
  251. 'viewOriginalDesc': { 'zh-cn': '添加“查看原图”链接', 'zh-hk': '添加「查看原圖」連結', 'zh-tw': '添加「查看原圖」連結', 'en': 'add "Original Picture" link' },
  252. 'viewOriginalText': { 'zh-cn': '查看原图', 'zh-hk': '查看原圖', 'zh-tw': '查看原圖', 'en': 'Original Picture' },
  253. 'expandShortenedLink': { 'zh-cn': '自动展开新浪 t.cn 短网址', 'zh-hk': '自動展開新浪 t.cn 短網址', 'zh-tw': '自動展開新浪 t.cn 短網址', 'en': 'Auto expand Sina shortened URL (t.cn)' },
  254. // 脚本
  255. 'scriptToolsTitle': { 'zh-cn': '脚本', 'zh-hk': '腳本', 'zh-tw': '腳本', 'en': 'Script' },
  256. 'useFastCreator': { 'zh-cn': '使用拖放快速创建过滤器', 'zh-hk': '使用拖放快速創建篩選器', 'zh-tw': '使用拖放快速創建篩選器', 'en': 'Use drag and drop to create filters' },
  257. 'blockHiddenWeiboDesc': { 'zh-cn': '告知服务器被隐藏的微博以避免再次加载', 'zh-hk': '告知伺服器被隱藏的微博以避免再次載入', 'zh-tw': '告知伺服器被隱藏的微博以避免再次載入', 'en': 'Send blocked Weibo to server to avoid load it again' },
  258. // 样式
  259. 'styleToolsTitle': { 'zh-cn': '外观', 'zh-hk': '外觀', 'zh-tw': '外觀', 'en': 'Appearance' },
  260. 'userstyleEditDesc': { 'zh-cn': '编辑微博自定义CSS', 'zh-hk': '編輯微博自訂CSS', 'zh-tw': '編輯微博自訂CSS', 'en': 'Edit Weibo Customize CSS' },
  261. 'userstyleEditDetails': { 'zh-cn': 'YAWF CSS: ', 'zh-hk': 'YAWF CSS: ', 'zh-tw': 'YAWF CSS: ', 'en': 'YAWF CSS: ' },
  262. 'whitelistHighlightDesc': { 'zh-cn': '高亮显示白名单的微博|背景色{{<color>}}|透明度{{<transparency>}}%', 'zh-hk': '高亮顯示白名單的微博|背景色{{<color>}}|透明度{{<transparency>}}%', 'zh-tw': '高亮顯示白名單的微博|背景色{{<color>}}|透明度{{<transparency>}}%', 'en': 'Highlight Weibo in whitelist with | background color {{<color>}} | transparency {{<transparency>}}%' },
  263. 'mainBackgroundColorOverride': { 'zh-cn': '首页背景|颜色{{<color>}}|透明度{{<transparency>}}%', 'zh-hk': '首頁背景|色彩{{<color>}}|透明度{{<transparency>}}%', 'zh-tw': '首頁背景|色彩{{<color>}}|透明度{{<transparency>}}%', 'en': 'Background color for home page | {{<color>}} | transparency {{<transparency>}}%' },
  264. 'profileBackgroundColorOverride': { 'zh-cn': '个人主页背景|颜色{{<color>}}|透明度{{<transparency>}}%', 'zh-hk': '個人主頁背景|色彩{{<color>}}|透明度{{<transparency>}}%', 'zh-tw': '個人主頁背景|色彩{{<color>}}|透明度{{<transparency>}}%', 'en': 'Background color for personal home page | {{<color>}} | transparency {{<transparency>}}%' },
  265. 'weiboOnly': {
  266. 'zh-cn': '阅读视图|宽度{{<width>}}px|快捷键{{<key>}}||{{<usebgc>}}使用指定背景色|{{<color>}}|透明度{{<transparency>}}%||{{<switch>}}在微博列表顶部显示快捷开关按钮',
  267. 'zh-hk': '閱讀視圖|寬度{{<width>}}px|快速鍵{{<key>}}||{{<usebgc>}}使用指定背景色|{{<color>}}|透明度{{<transparency>}}%||{{<switch>}}在微博清單頂部顯示快速開關按鈕',
  268. 'zh-tw': '閱讀視圖|寬度{{<width>}}px|快速鍵{{<key>}}||{{<usebgc>}}使用指定背景色|{{<color>}}|透明度{{<transparency>}}%||{{<switch>}}在微博清單頂部顯示快速開關按鈕',
  269. 'en': 'Reading View | width {{<width>}}px | shortcut {{<key>}} || {{<usebgc>}} override background color | with {{<color>}} | transparency {{<transparency>}} || {{<switch>}} show switch button at top of Weibo list'
  270. },
  271. 'weiboOnlyButton': { 'zh-cn': '切换视图', 'zh-hk': '切換視圖', 'zh-tw': '切換視圖', 'en': 'Switch View' },
  272. 'userstyleTitle': {
  273. 'zh-cn': '<span>自定义CSS<a class="yawf-userstyles-tip" href="https://userstyles.org/styles/browse/weibo" target="_blank">在 userstyles.org 上搜索样式</a></span>{{}}',
  274. 'zh-hk': '<span>自訂CSS<a class="yawf-userstyles-tip" href="https://userstyles.org/styles/browse/weibo" target="_blank">在 userstyles.org 上搜尋樣式</a></span>{{}}',
  275. 'zh-tw': '<span>自訂CSS<a class="yawf-userstyles-tip" href="https://userstyles.org/styles/browse/weibo" target="_blank">在 userstyles.org 上搜尋樣式</a></span>{{}}',
  276. 'en': '<span>Customize CSS<a class="yawf-userstyles-tip" href="https://userstyles.org/styles/browse/weibo" target="_blank">Search styles on userstyles.org</a></span>{{}}'
  277. },
  278. // 脚本
  279. 'scriptFilterGroupTitle': { 'zh-cn': '脚本', 'zh-hk': '腳本', 'zh-tw': '腳本', 'en': 'Script' },
  280. // 导入导出
  281. 'configImportAndExport': { 'zh-cn': '设置', 'zh-hk': '設定', 'zh-tw': '設定', 'en': 'Setting' },
  282. 'configImportButton': { 'zh-cn': '导入', 'zh-hk': '匯入', 'zh-tw': '匯入', 'en': 'Import' },
  283. 'configImportWarningTitle': { 'zh-cn': '设置导入', 'zh-hk': '設定匯入', 'zh-tw': '設定匯入', 'en': 'Setting Import' },
  284. 'configImportWarning': {
  285. 'zh-cn': '导入的设置会覆盖您当前已有的设置,确实要导入设置吗?',
  286. 'zh-hk': '匯入的設定會覆蓋您當前已有的設定,您確定要匯入設定嗎?',
  287. 'zh-tw': '匯入的設定會覆蓋您當前已有的設定,您確定要匯入設定嗎?',
  288. 'en': 'The imported settings may replace your current settings. Are you sure you want to import this file?'
  289. },
  290. 'configImportSuccessTitle': { 'zh-cn': '设置导入完成', 'zh-hk': '設定匯入完成', 'zh-tw': '設定匯入完成', 'en': 'Import settings' },
  291. 'configImportSuccess': { 'zh-cn': '已经成功地导入了设置', 'zh-hk': '已经成功地匯入了設定', 'zh-tw': '已经成功地匯入了設定', 'en': 'Successfully imported settings' },
  292. 'configImportFailTitle': { 'zh-cn': '设置导入失败', 'zh-hk': '設定匯入失败', 'zh-tw': '設定匯入失败', 'en': 'Import settings' },
  293. 'configImportFail': {
  294. 'zh-cn': '导入设置文件时出现错误,可能是使用了错误的文件,文件已损坏或文件的版本不支持',
  295. 'zh-hk': '匯入設定檔案時出現錯誤,可能是使用了錯誤的檔案,檔案已損壞或為不支援的版本',
  296. 'zh-tw': '匯入設定檔案時出現錯誤,可能是使用了錯誤的檔案,檔案已損壞或為不支援的版本',
  297. 'en': 'Error occurred during importing process. Wrong file may be used, the file may be broken, or the version of setting file is not supported.'
  298. },
  299. 'configExportButton': { 'zh-cn': '导出', 'zh-hk': '匯出', 'zh-tw': '匯出', 'en': 'Export' },
  300. 'configResetButton': { 'zh-cn': '重置', 'zh-hk': '重設', 'zh-tw': '重設', 'en': 'Reset' },
  301. 'configResetWarningTitle': { 'zh-cn': '设置重置', 'zh-hk': '設定重設', 'zh-tw': '設定重設', 'en': 'Setting Reset' },
  302. 'configResetWarning': { 'zh-cn': '这将会清空您当前的所有配置,确实要重置设置吗?', 'zh-hk': '這將會清空您當前的所有設定,您確定要重置設定嗎?', 'zh-tw': '這將會清空您當前的所有設定,您確定要重置設定嗎?', 'en': 'You are deleting all your settings. Are you sure you want to reset your settings?' },
  303. // 调试
  304. 'scriptDebugTitle': { 'zh-cn': '调试', 'zh-hk': '偵錯', 'zh-tw': '偵錯', 'en': 'Debug' },
  305. 'scriptDebug': { 'zh-cn': '在控制台打印调试信息', 'zh-hk': '將偵錯訊息列印到主控台', 'zh-tw': '將偵錯訊息列印到主控台', 'en': 'Print debug info to console' },
  306. // 关于
  307. 'scriptAboutTitle': { 'zh-cn': '关于', 'zh-hk': '關於', 'zh-tw': '關於', 'en': 'About' },
  308. 'scriptAbout': {
  309. 'zh-cn': '<p>Yet Another Weibo Filter (YAWF) {{version}}</p><p>YAWF 使用 MIT 协议授权。您可以访问<a target="_blank" href="https://tiansh.github.io/yawf/" rel="noreferrer">脚本主页</a>获取详细信息。<br />如果您在使用过程中遇到任何脚本的错误,或对脚本有任何建议,您可以到<a target="_blank" href="https://tiansh.github.io/yawf/issues.html" rel="noreferrer">反馈页面</a>提供报告,或直接<a target="_blank" href="http://weibo.com/tsh90/weibo" rel="noreferrer">私信作者</a>;反馈前建议先阅读<a target="_blank" href="https://tiansh.github.io/yawf/fqa.html" rel="noreferrer">常见问题</a>。</p><p>本脚本参考并使用了<a target="_blank" href="https://code.google.com/p/weibo-content-filter/" rel="noreferrer">眼不见心不烦</a>脚本的部分代码。</p>',
  310. 'zh-hk': '<p>Yet Another Weibo Filter (YAWF) {{version}}</p><p>YAWF 使用 MIT 協定授權。您可以訪問<a target="_blank" href="https://tiansh.github.io/yawf/" rel="noreferrer">腳本主頁</a>獲取詳細資訊。<br />如果您在使用過程中遇到任何腳本的錯誤,或對腳本有任何建議,您可以到<a target="_blank" href="https://tiansh.github.io/yawf/issues.html" rel="noreferrer">回饋頁面</a>提供報告,或直接<a target="_blank" href="http://weibo.com/tsh90/weibo" rel="noreferrer">私信作者</a>;回饋前建議先閱讀<a target="_blank" href="https://tiansh.github.io/yawf/fqa.html" rel="noreferrer">常見問題(簡體)</a>。</p><p>本腳本參考並使用了<a target="_blank" href="https://code.google.com/p/weibo-content-filter/" rel="noreferrer">眼不見心不煩</a>腳本的部分原始碼。</p>',
  311. 'zh-tw': '<p>Yet Another Weibo Filter (YAWF) {{version}}</p><p>YAWF 使用 MIT 協定授權。您可以訪問<a target="_blank" href="https://tiansh.github.io/yawf/" rel="noreferrer">腳本主頁</a>獲取詳細資訊。<br />如果您在使用過程中遇到任何腳本的錯誤,或對腳本有任何建議,您可以到<a target="_blank" href="https://tiansh.github.io/yawf/issues.html" rel="noreferrer">回饋頁面</a>提供報告,或直接<a target="_blank" href="http://weibo.com/tsh90/weibo" rel="noreferrer">私信作者</a>;回饋前建議先閱讀<a target="_blank" href="https://tiansh.github.io/yawf/fqa.html" rel="noreferrer">常見問題(簡體)</a>。</p><p>本腳本參考並使用了<a target="_blank" href="https://code.google.com/p/weibo-content-filter/" rel="noreferrer">眼不見心不煩</a>腳本的部分原始碼。</p>',
  312. 'en': '<p>Yet Another Weibo Filter (YAWF) {{version}}</p><p>YAWF is under the MIT License. You may want to visit <a target="_blank" href="https://tiansh.github.io/yawf/" rel="noreferrer">project homepage</a> for more information.<br />If you find any bugs or have feature request, please report them in the <a target="_blank" href="https://tiansh.github.io/yawf/issues.html" rel="noreferrer">feedback page</a>, or <a target="_blank" href="http://weibo.com/tsh90/weibo" rel="noreferrer">send message to author</a>. Please read <a target="_blank" href="https://tiansh.github.io/yawf/fqa.html" rel="noreferrer">FQA (Chinese)</a> page for common questions.</p><p>Some codes of this script come from <a target="_blank" href="https://code.google.com/p/weibo-content-filter/" rel="noreferrer"><span lang="zh-cn">眼不见心不烦</span> (Weibo Content Filter)</a> script.</p>',
  313. },
  314. // 拖拽
  315. 'dropAreaTitle': { 'zh-cn': '拖放至此<br />快速创建过滤器', 'zh-hk': '拖放至此<br />快速創建篩選器', 'zh-tw': '拖放至此<br />快速創建篩選器', 'en': 'Drop Here to Create Filter' },
  316. 'dropAreaText': { 'zh-cn': '将文字或链接拖放至此,快速创建过滤器。', 'zh-hk': '將文字或連結拖放至此,快速創建篩選器。', 'zh-tw': '將文字或連結拖放至此,快速創建篩選器。', 'en': 'Drop text or link here to create filter.' },
  317. 'fastCreateChoseTitle': { 'zh-cn': '创建过滤器', 'zh-hk': '創建篩篩器', 'zh-tw': '創建篩篩器', 'en': 'Create Filter' },
  318. 'fastFilterChoseText': { 'zh-cn': '请选择要创建的过滤器:', 'zh-hk': '請選擇要創建的篩選器:', 'zh-tw': '請選擇要創建的篩選器:', 'en': 'Chose the filter(s) you want:' },
  319. };
  320.  
  321. // 页面常量
  322. var html = {
  323. '|': '</label><label>', // 先关闭前面的label,再从后面开一个,所以这里没写反
  324. '||': '</label><br /><label>',
  325. 'select': '<select>{{options}}</select>',
  326. 'option': '<option value="{{value}}">{{{text}}}</option>',
  327. // 对话框
  328. 'cover': '<div node-type="outer" style="position: fixed; top: 0px; left: 0px; width: 100%; height: 100%; background: #000; opacity: 0.3; z-index: 10001;"></div>',
  329. 'dialog': '<div style="position: absolute; z-index: 10001;" node-type="outer" class="W_layer yawf-Layer" id="{{id}}"><div class="bg"><table cellspacing="0" cellpadding="0" border="0"><tbody><tr><td><div node-type="layoutContent" class="content"><div node-type="title" class="title"><span node-type="title_content">{{title}}</span></div><a node-type="close" title="{{closeButtonTitle}}" class="W_close" href="javascript:void(0);"></a><div node-type="inner"></div></div></td></tr></tbody></table></div></div>',
  330. 'alert': '<div style="position: absolute; z-index: 10001;" node-type="outer" class="W_layer yawf-Layer" id="{{id}}"><div class="bg"><table cellspacing="0" cellpadding="0" border="0"><tbody><tr><td><div node-type="layoutContent" class="content"><div node-type="title" class="title" style=""><span node-type="title_content">{{title}}</span></div><a node-type="close" title="{{closeButtonTitle}}" class="W_close" href="javascript:void(0);"></a><div node-type="inner"><div class="layer_point" node-type="outer"><dl class="point clearfix"><dt><span node-type="icon" class="icon_{{icon}}M"></span></dt><dd node-type="inner"><p node-type="textLarge" class="S_txt1">{{text}}</p><p node-type="textSmall" class="S_txt2"></p></dd></dl><div class="btn"><a node-type="OK" class="W_btn_a" href="javascript:void(0)"><span class="btn_30px W_f14">{{okButtonTitle}}</span></a></div></div></div></div></td></tr></tbody></table></div></div>',
  331. 'confirm': '<div style="position: absolute; z-index: 10001;" node-type="outer" class="W_layer yawf-Layer" id="{{id}}"><div class="bg"><table cellspacing="0" cellpadding="0" border="0"><tbody><tr><td><div node-type="layoutContent" class="content"><div node-type="title" class="title" style=""><span node-type="title_content">{{title}}</span></div><a node-type="close" title="{{closeButtonTitle}}" class="W_close" href="javascript:void(0);"></a><div node-type="inner"><div class="layer_point" node-type="outer"><dl class="point clearfix"><dt><span node-type="icon" class="icon_{{icon}}M"></span></dt><dd node-type="inner"><p node-type="textLarge" class="S_txt1">{{text}}</p><p node-type="textComplex" class="S_txt2" style="display: none;"></p><p node-type="textSmall" class="S_txt2" style="display: none;"></p></dd></dl><div class="btn"><a node-type="OK" class="W_btn_a" href="javascript:void(0)"><span class="btn_30px W_f14">{{okButtonTitle}}</span></a><a node-type="cancel" class="W_btn_b" href="javascript:void(0)"><span class="btn_30px W_f14">{{cancelButtonTitle}}</span></a></div></div></div></div></td></tr></tbody></table></div></div>',
  332. // 漏斗图标
  333. 'icon': '<div class="gn_setting" node-type="filter"><i><a class="gn_tab gn_filter" href="#"><span class="ico">{{filter}}</span></a></i></div>',
  334. // 设置窗口
  335. 'configHeaderTop': '<div class="profile_tab S_line5 yawf-config-header" node-type="yawf-config-header"><ul class="pftb_ul S_line1">',
  336. 'configHeaderItem': '<li class="pftb_itm S_line1 {{liclass}}"><a class="pftb_lk S_line5 S_txt1 {{aclass}}" action-type="tab_item" onclick="return false;" href="javascript:void(0);">{{name}}</a>',
  337. 'configHeaderBottom': '</ul></div>',
  338. 'configLayerTop': '<div node-type="yawf-config-body" class="yawf-config-body">',
  339. 'configLayerItem': '<div class="{{name}} yawf-config-layer" node-type="{{name}}" style="display: none;"></div>',
  340. 'configLayerBottom': '</div>',
  341. 'configFooter': '',
  342. // 设置窗口内文字
  343. 'configSubtitle': '<div class="yawf-groupSubtitle">{{{text}}}</div>',
  344. 'configText': '<div class="yawf-groupText">{{{text}}}</div>',
  345. 'configRemark': '<div class="yawf-groupRemark">{{{text}}}</div>',
  346. // 设置项
  347. 'configBoolean': '<div class="yawf-configBoolean yawf-configItem"><label>{{text}}</label></div>',
  348. 'configBooleanInput': '<div class="yawf-configInput yawf-configBooleanInput"><input id="yawf-{{key}}" class="W_checkbox yawf-configBooleanInput" type="checkbox" name="yawf-{{key}}"></div>',
  349. 'configSelect': '<div class="yawf-configSelect yawf-configItem"><label>{{text}}</label></div>',
  350. 'configSelectInput': '<div class="yawf-configInput yawf-configSelectInput"><select class="yawf-configSelectSelect" name="yawf-{{key}}"></select></div>',
  351. 'configString': '<div class="yawf-configString yawf-configItem"><label>{{text}}</label></div>',
  352. 'configStringInput': '<div class="yawf-configInput yawf-configStringInput"><textarea id="yawf-{{key}}" class="W_input yawf-configStringInput" name="yawf-{{key}}"></textarea></div>',
  353. 'configColor': '<div class="yawf-configColor yawf-configItem"><label>{{text}}</label></div>',
  354. 'configColorInput': '<div class="yawf-configInput yawf-configColorInput"><input type="color" class="W_f14" style="width: 40px;" /></div>',
  355. 'configNumber': '<div class="yawf-configNumber yawf-configItem"><label>{{text}}</label></div>',
  356. 'configNumberInput': '<div class="yawf-configInput yawf-configNumberInput"><input type="number" class="W_f14" style="width: 60px;" /></div>',
  357. 'configRange': '<div class="yawf-configRange yawf-configItem"><label>{{text}}</label></div>',
  358. 'configRangeInput': '<div class="yawf-configInput yawf-configRangeInput"><input type="number" min="0" max="100" maxlength="3" class="W_f14" style="width: 45px; text-align: right;" /><div class="yawf-range-container"><input type="range" style="height: 1em; width: 66px; margin-left: 7px; margin-right: 7px; " tabindex="-1" /></div></div>',
  359. 'configKey': '<div class="yawf-configKey yawf-configItem"><label>{{text}}</label></div>',
  360. 'configKeyInput': '<div class="yawf-configInput yawf-configKeyInput"><button class="W_f14 yawf-configKeyName"></button><input type="hidden" /></div>',
  361. 'configStrings': '<div class="yawf-configStrings yawf-configItem"><form action="#"><label><span class="yawf-configDesc yawf-configStringsDesc">{{{text}}}</span><input id="yawf-{{key}}" class="W_input yawf-configStringsInput" type="text" name="yawf-{{key}}"></label><button id="yawf-add-{{key}}" class="W_btn_a yawf-configAdd" type="submit"><span>{{configStringsAdd}}</span></button></form><ul class="yawf-configStringsItems"></ul></div>',
  362. 'configStringsItem': '<li class="W_btn_arrow tag yawf-configStringsItem"><span>{{[item]}}<a class="W_ico12 icon_close" href="javascript:void(0);"></a></span></li>',
  363. 'configUsers': '<div class="yawf-configUsers yawf-configItem"><form action="#"><label><span class="yawf-configDesc yawf-configUsersDesc">{{{text}}}</span><input id="yawf-{{key}}" class="W_input yawf-configUsersInput" type="text" name="yawf-{{key}}"></label><button id="yawf-add-{{key}}" class="W_btn_a yawf-configAdd" type="submit"><span>{{configUsersAdd}}</span></button></form><ul class="yawf-configUsersItems"></ul></div>',
  364. 'configUsersItem': '<li class="yawf-configUsersItem"><div class="shield_object_card"><div class="card_bg clearfix"><div class="card_pic"><span class="pic"><img class="W_face_radius" width="50" height="50" alt="" src="{{avatar}}"></span></div><div class="card_content"><div class="object_info clearfix"><p class="W_fl"><span class="object_name" uid="{{id}}" title="{{name}}">{{name}}</span></p><p class="W_fr"><a class="W_ico12 icon_close" action-data="uid={{id}}" href="javascript:void(0);"></a></p></div><div class="other_info"></div></div></div></div></li>',
  365. 'configPrefill': '<span class="yawf-configPrefill" id="{{id}}"></span>',
  366. // 导入导出
  367. 'configImportExport': '<div class="yawf-configImportExport yawf-configItem"><label><input type="file" style=" width: 1px; height: 1px; margin: 0 -1px 0 0; opacity: 0;" /><span node-type="import" class="W_btn_b" action-type="import"><span class="W_f14">{{configImportButton}}</span></span></label><a node-type="export" class="W_btn_b" action-type="export" href="javascript:;"><span class="W_f14">{{configExportButton}}</span></a><a node-type="reset" class="W_btn_b" action-type="reset" href="javascript:;"><span class="W_f14">{{configResetButton}}</span></a></div>',
  368. // 查看原图
  369. 'viewOriginalLink': '<a target="_blank" class="show_big" suda-data="key=tblog_newimage_feed&value=view_original" action-type="maximum" href="javascript:;"><em class="W_ico12 ico_showbig"></em>{{viewOriginalText}}</a><i class="W_vline">|</i>',
  370. // 拖拽
  371. 'dropArea': '<div id="yawf-drop-area" class="display: none;"><div class="yawf-drop-area-desc"><div class="yawf-drop-area-title">{{dropAreaTitle}}</div><div class="yawf-drop-area-text">{{dropAreaText}}</div></div><div contenteditable="true" id="yawf-drop-area-content"></div></div>',
  372. 'fastFilterHeader': '<div id="yawf-fast-filter-chose"><div class="yawf-fast-filter-option"><span class="yawf-fast-filter-text">{{fastFilterChoseText}}</span><ul id="yawf-fast-filter-list">',
  373. 'fastFilterItem': '<li class="yawf-fast-filter-item"><label><input class="W_checkbox yawf-configBooleanInput" type="checkbox"><span class="yawf-fastFilterItemInner"></span></label><select value="blacklist"><option value="whitelist">{{whitelistActionDesc}}</option><option value="blacklist">{{blacklistActionDesc}}</option><option value="foldlist">{{foldlistActionDesc}}</option></select></li>',
  374. 'fastFilterFooter': '</ul></div><div class="btn clearfix"><a node-type="ok" class="W_btn_a" action-type="ok" href="javascript:;"><span class="btn_30px W_f14">{{okButtonTitle}}</span></a><a node-type="cancel" class="W_btn_b" action-type="cancel" href="javascript:;"><span class="btn_30px W_f14">{{cancelButtonTitle}}</span></a></div></div>',
  375. 'fastFilterString': '<label><span></span></label>',
  376. 'fastFilterStringInput': '<input width="12" class="input_default" type="text" />',
  377. // 只看微博列表
  378. 'weiboOnlyButton': '<div class="right_item"><div><a class="W_btn_round2" href="javascript:void(0);" title="{{text}}{{shortcut}}"><span>{{text}}</span></a></div></div></div>',
  379. // 分组或特别关注的未读提示
  380. 'noticeContainer': '<div class="WB_feed_type SW_fun S_line2" action-type="feed_list_item" yawf-display="notice"></div>',
  381. };
  382.  
  383. var url = {
  384. 'newcard': '/aj/user/newcard?type=1&{{query}}&_t=1&callback={{callback}}',
  385. 'view_ori': 'http://photo.weibo.com/{{uid}}/wbphotos/large/mid/{{mid}}/pid/{{pid}}',
  386. 'block_wb': '/aj/user/block?_wv=5&__rnd={{rnd}}',
  387. };
  388.  
  389. // 将按键编号或将显示编号对应名称
  390. var keys = (function () {
  391. var ctrl = 1 << 8, shift = 1 << 9, alt = 1 << 10, meta = 1 << 11, key = ctrl - 1;
  392. var namelist = '#0;#1;#2;Cancel;#4;#5;Help;#7;BackSpace;TAB;#10;#11;Clear;Enter;EnterSpecial;#15;;;;Pause;CapsLock;Kana;Eisu;Junja;Final;Hanja;#26;Esc;Convert;Nonconvert;Accept;ModeChange;Space;PageUp;PageDown;End;Home;Left;Up;Right;Down;Select;Print;Execute;PrintScreen;Insert;Delete;#47;0;1;2;3;4;5;6;7;8;9;Colon;Semicolon;LessThan;Equals;GreaterThan;QuestionMark;At;A;B;C;D;E;F;G;H;I;J;K;L;M;N;O;P;Q;R;S;T;U;V;W;X;Y;Z;Win;#92;ContextMenu;#94;Sleep;NumPad0;NumPad1;NumPad2;NumPad3;NumPad4;NumPad5;NumPad6;NumPad7;NumPad8;NumPad9;Multiply;Add;Separator;Subtract;Decimal;Divide;F1;F2;F3;F4;F5;F6;F7;F8;F9;F10;F11;F12;F13;F14;F15;F16;F17;F18;F19;F20;F21;F22;F23;F24;#136;#137;#138;#139;#140;#141;#142;#143;NumLock;ScrollLocK;WIN_OEM_FJ_JISHO;WIN_OEM_FJ_MASSHOU;WIN_OEM_FJ_TOUROKU;WIN_OEM_FJ_LOYA;WIN_OEM_FJ_ROYA;#151;#152;#153;#154;#155;#156;#157;#158;#159;Circumflex;Exclamation;DoubleQuote;Hash;Dollar;Percent;Ampersand;Underscore;OpenParen;CloseParen;Asterisk;Plus;Pipe;HyphenMinus;OpenCurlyBracket;CloseCurlyBracket;Tilde;#177;#178;#179;#180;VolumeMute;VolumeDown;VolumeUp;#184;#185;#186;#187;Comma;#189;Period;Slash;BackQuote;#193;#194;#195;#196;#197;#198;#199;#200;#201;#202;#203;#204;#205;#206;#207;#208;#209;#210;#211;#212;#213;#214;#215;#216;#217;#218;OpenBracket;BackSlash;CloseBracket;Quote;#223;;AltGr;#226;WIN_ICO_HELP;WIN_ICO_00;#229;WIN_ICO_CLEAR;#231;#232;WIN_OEM_RESET;WIN_OEM_JUMP;WIN_OEM_PA1;WIN_OEM_PA2;WIN_OEM_PA3;WIN_OEM_WSCTRL;WIN_OEM_CUSEL;WIN_OEM_ATTN;WIN_OEM_FINISH;WIN_OEM_COPY;WIN_OEM_AUTO;WIN_OEM_ENLW;WIN_OEM_BACKTAB;Attn;Crsel;Exsel;Ereof;Play;Zoom;#252;PA1;WIN_OEM_CLEAR;#255'.split(';');
  393. // 对一个按键事件做编号
  394. var get = function (e) {
  395. var code = e.keyCode & key;
  396. if (e.ctrlKey) code |= ctrl;
  397. if (e.shiftKey) code |= shift;
  398. if (e.altKey) code |= alt;
  399. if (e.metaKey) code |= meta;
  400. return code;
  401. };
  402. // 给一个编号,转换为键名
  403. var name = function (n) {
  404. if (n === 0) return text.disabledKey;
  405. var ret = '';
  406. if (n & ctrl) ret += 'Ctrl-';
  407. if (n & shift) ret += 'Shift-';
  408. if (n & alt) ret += 'Alt-';
  409. if (n & meta) ret += 'Meta-';
  410. ret += namelist[n & key];
  411. if (ret.slice(-1) === '-') ret = ret.slice(0, -1);
  412. return ret;
  413. };
  414. // 注册全局监听按键
  415. var triggers = {};
  416. var reg = function (key, callback) {
  417. triggers[key] = triggers[key] || [];
  418. triggers[key].push(withTry(callback));
  419. };
  420. // 监听按键
  421. var baseEvent = function (e) {
  422. var code = get(e);
  423. if (!triggers[code]) return [];
  424. e.stopPropagation(); e.preventDefault();
  425. return triggers[code];
  426. };
  427. document.addEventListener('keydown', function (e) {
  428. baseEvent(e).forEach(function (f) { f(); })
  429. });
  430. document.addEventListener('keyup', baseEvent);
  431. return {
  432. 'get': get,
  433. 'name': name,
  434. 'reg': reg,
  435. };
  436. }());
  437.  
  438.  
  439. // 根据用户界面上的语言做不同调整
  440. var i18n = (function () {
  441. var defaultLang = 'zh-cn';
  442. var lang = null;
  443. var pending = [];
  444. var chose = function (langObj) {
  445. langObj.local = langObj[lang] || langObj[defaultLang];
  446. };
  447. return function (l) {
  448. lang = l;
  449. pending.map(chose);
  450. pending = [];
  451. i18n = chose;
  452. i18n.lang = l;
  453. };
  454. }());
  455.  
  456. // 将字符串用&#dd的形式转义
  457. var escapeXml = function (s) {
  458. return s.replace(/./g, function (c) { return '&#' + c.charCodeAt(0); });
  459. };
  460.  
  461. // 以参数填充字符串
  462. var fillStr = function (base, func) {
  463. var argdatas = Array.apply(Array, arguments).slice(1);
  464. var datas = argdatas.concat([text]);
  465. var parseFunction;
  466. if (typeof func === 'function') parseFunction = func;
  467. else parseFunction = function (text) {
  468. var ret = null;
  469. datas.some(function (data) {
  470. if (typeof data === 'object' && text in data) ret = '' + data[text];
  471. return ret !== null;
  472. });
  473. return ret;
  474. };
  475. return base.replace(/{{([\[{]?([a-zA-Z0-9_-]*)[\]}]?)}}/g, function (o, i, p) {
  476. var ret = parseFunction(p);
  477. if (ret == null) return o;
  478. if (i[0] === '{') return ret = fillStr(ret, parseFunction);
  479. if (i[0] === '[') return escapeXml(ret);
  480. return ret;
  481. });
  482. };
  483.  
  484. // 设置项
  485. var config = function (uid) {
  486. var config = {}, keys = [], onputs = [], storageKey = 'user' + uid + 'config';
  487. var tonputs = function (key, value, oldValue) {
  488. onputs.map(function (f) { f(key, value, oldValue); });
  489. };
  490. // 读取到内存
  491. var read = function () {
  492. try { config = JSON.parse(GM_getValue(storageKey, '{}')); }
  493. catch (e) { config = {}; }
  494. };
  495. // 从内存写出
  496. var write = function () {
  497. GM_setValue(storageKey, JSON.stringify(config));
  498. };
  499. // 写入到内存
  500. var put = function (key, value) {
  501. if (keys.indexOf(key) === -1) return;
  502. tonputs(key, value, config[key]);
  503. config[key] = value;
  504. write();
  505. return value;
  506. };
  507. // 从内存读取
  508. var get = function (key, value, type) {
  509. read();
  510. if (!(key in config)) return value;
  511. var val = config[key];
  512. if (typeof val === 'undefined') return value;
  513. if (type && (val === null || val.constructor !== type)) return value;
  514. return val;
  515. };
  516. // 当内存配置被修改时调用
  517. var onput = function (f) {
  518. onputs.push(f);
  519. };
  520. // 从字串导入
  521. var import_ = function (s) {
  522. try {
  523. clear();
  524. s = JSON.parse(s).conf;
  525. Object.keys(s).forEach(function (key) {
  526. put(key, s[key]);
  527. });
  528. write();
  529. return true;
  530. } catch (e) { }
  531. return false;
  532. };
  533. // 导出成为字串
  534. var export_ = function () {
  535. var info = GM_info || {}, script = info.script || {};
  536. var conf = {};
  537. Object.keys(config)
  538. .filter(function (x) { return x.indexOf('._') === -1; })
  539. .forEach(function (x) { conf[x] = config[x]; })
  540. return JSON.stringify({
  541. 'ua': navigator.userAgent,
  542. 'yawf': script.name,
  543. 'ver': script.version,
  544. 'gm': (info.scriptHandler || '') + info.version,
  545. 'conf': conf,
  546. }, null, 2);
  547. };
  548. // 清空设置
  549. var clear = function () {
  550. config = {};
  551. tonputs();
  552. write();
  553. };
  554. // 注册键
  555. var reg = function (key) { keys.push(key); };
  556. // 初始化
  557. return {
  558. 'uid': uid,
  559. 'put': put, 'get': get, 'onput': onput,
  560. 'read': read, 'write': write,
  561. 'import': import_, 'export': export_,
  562. 'clear': clear,
  563. 'reg': reg,
  564. };
  565. };
  566.  
  567.  
  568. // 微博过滤规则
  569. var rules = (function () {
  570. var list = [];
  571. var add = function (priority, rule) {
  572. list.push({ 'priority': priority, 'rule': rule });
  573. list.sort(function (x, y) { return y.priority - x.priority; });
  574. };
  575. var parse = function (feed) {
  576. var result = null;
  577. list.some(function (item) {
  578. try { result = item.rule(feed) || result; }
  579. catch (e) { debug('error while parsing rule %o: %o', item.rule, e); }
  580. if (result) debug('%o(%o) -> %s', item.rule, feed, result);
  581. return result;
  582. });
  583. return result;
  584. };
  585. return {
  586. 'add': add,
  587. 'parse': parse,
  588. };
  589. }());
  590.  
  591. var debug = GM_getValue('debug', false) &&
  592. console && console.log && console.log.bind(console) ||
  593. function () { };
  594.  
  595. // 显示右上角过滤器图标
  596. var showIcon = function () {
  597. var p = document.querySelector('.WB_global_nav .gn_person');
  598. if (!p) return setTimeout(showIcon, 100);
  599. var d = cewih('div', html.icon).firstChild;
  600. p.appendChild(d);
  601. var f = document.querySelector('.gn_filter');
  602. f.addEventListener('click', function (e) {
  603. filters.showDialog();
  604. e.preventDefault();
  605. });
  606. };
  607.  
  608. // 对话框
  609. var Form = function (dom, display, details) {
  610. var ok = dom.querySelector('[node-type="OK"]');
  611. var cancel = dom.querySelector('[node-type="cancel"]');
  612. var close = dom.querySelector('[node-type="close"]');
  613. var title = dom.querySelector('.title');
  614. var mouse = null, pos;
  615. // 定位对话框的位置
  616. var setPos = function (pos) {
  617. var left = pos[0], top = pos[1];
  618. left = Math.min(Math.max(0, left), document.body.clientWidth - dom.clientWidth - 2);
  619. top = Math.min(Math.max(pageYOffset, top), pageYOffset + window.innerHeight - dom.clientHeight - 2);
  620. dom.style.left = left + 'px';
  621. dom.style.top = top + 'px';
  622. return [left, top];
  623. };
  624. // 开始拖拽
  625. var dragMoveStart = function (e) {
  626. mouse = [e.clientX, e.clientY];
  627. document.addEventListener('mousemove', dragMove);
  628. document.addEventListener('mouseup', dragMoveDone);
  629. dom.classList.add('yawf-drag');
  630. if (dom.setCapture) { dom.setCapture(); }
  631. };
  632. // 拖拽移动
  633. var dragMove = function (e) {
  634. var mouse_new = [e.clientX, e.clientY];
  635. pos[0] += mouse_new[0] - mouse[0];
  636. pos[1] += mouse_new[1] - mouse[1];
  637. setPos(pos);
  638. mouse = mouse_new;
  639. };
  640. // 拖拽结束
  641. var dragMoveDone = function () {
  642. document.removeEventListener('mousemove', dragMove);
  643. document.removeEventListener('mouseup', dragMoveDone);
  644. dom.classList.remove('yawf-drag');
  645. if (dom.releaseCapture) { dom.releaseCapture(); }
  646. pos = setPos(pos);
  647. mouse = null;
  648. };
  649. // 标题栏可以拖拽
  650. if (title) {
  651. title.style.cursor = 'move';
  652. title.addEventListener('mousedown', dragMoveStart);
  653. }
  654. // 确定取消等按钮
  655. if (details.onOk) if (ok) ok.addEventListener('click', details.onOk);
  656. if (details.onCancel) {
  657. if (cancel) cancel.addEventListener('click', details.onCancel);
  658. if (close) close.addEventListener('click', details.onCancel);
  659. }
  660. // 背景遮罩
  661. var cover = cewih('div', html.cover).firstChild;
  662. // 响应按键
  663. var keys = function (e) {
  664. if (e.keyCode === 13) if (ok) ok.click(); // Enter
  665. if (e.keyCode === 27) if (close) close.click(); // Esc
  666. };
  667. // 关闭对话框
  668. var hide = function () {
  669. document.body.removeChild(dom);
  670. document.body.removeChild(cover);
  671. document.removeEventListener('keypress', keys);
  672. };
  673. // 显示对话框
  674. var show = function (top, left) {
  675. document.body.appendChild(cover);
  676. document.body.appendChild(dom);
  677. if (top == null) top = (window.innerHeight - dom.clientHeight) / 2;
  678. if (left == null) left = (window.innerWidth - dom.clientWidth) / 2;
  679. pos = [left, top + pageYOffset];
  680. setPos(pos);
  681. document.addEventListener('keypress', keys);
  682. document.activeElement.blur();
  683. };
  684. if (display) show();
  685. if (ok) ok.addEventListener('click', hide);
  686. if (cancel) cancel.addEventListener('click', hide);
  687. if (close) close.addEventListener('click', hide);
  688. return { 'hide': hide, 'show': show };
  689. };
  690.  
  691. // 显示一个对话框
  692. var Dialog = function (id, title, fillFun) {
  693. var dom = cewih('div', fillStr(html.dialog, { 'id': id, 'title': fillStr(title) })).firstChild;
  694. var form = Form(dom, false, {});
  695. fillFun(dom.querySelector('[node-type="inner"]'));
  696. return form;
  697. };
  698.  
  699. // 显示一个提示框
  700. var Alert = function (id, details) {
  701. var dom = cewih('div', fillStr(html.alert, { 'id': id, 'title': details.title, 'text': details.text, 'icon': details.icon || 'warn' })).firstChild;
  702. var form = Form(dom, true, details);
  703. return form;
  704. };
  705.  
  706. // 显示一个确定框
  707. var Confirm = function (id, details) {
  708. var dom = cewih('div', fillStr(html.confirm, { 'id': id, 'title': details.title, 'text': details.text, 'icon': details.icon || 'question' })).firstChild;
  709. var form = Form(dom, true, details);
  710. return form;
  711. };
  712.  
  713. // 延迟调用函数
  714. var call = function (f) {
  715. setTimeout.bind(this, f, 0).apply(null, Array.apply(Array, arguments).slice(1));
  716. };
  717.  
  718. // 套上try-catch
  719. var withTry = function (f, fc) {
  720. return function () {
  721. try { f.apply(this, arguments); }
  722. catch (e) {
  723. debug('Exception while run %o: %o (%o)', f, e, e.stack);
  724. if (fc) fc(e);
  725. }
  726. };
  727. };
  728.  
  729. // 管理样式
  730. var css = (function () {
  731. var styleText = '';
  732. var fun = function (css) { return fun.add.bind(fun, css); };
  733. fun.init = function () { GM_addStyle(styleText); };
  734. fun.add = function (css) { styleText += css + '\n'; };
  735. return fun;
  736. }());
  737.  
  738. // 产生一个假的回调函数
  739. var dateStr = (function () {
  740. var last = 0;
  741. return function () {
  742. return '' + (last = Math.max(last + 1, Number(new Date())));
  743. };
  744. }());
  745.  
  746. // 维护账号信息,用于显示
  747. var account = (function () {
  748. var idCache = {}, nameCache = {}, working = {};
  749. var request = function (queryStr, onsucc, onerror) {
  750. // 如果同时已经有了同类请求则等待那个请求的返回
  751. if (working[queryStr]) return working[queryStr].push([onsucc, onerror]);
  752. working[queryStr] = [[onsucc, onerror]];
  753. var done = function (success, data) {
  754. working[queryStr].forEach(function (w) { w[success ? 0 : 1](data); });
  755. delete working[queryStr];
  756. };
  757. // 请求获取
  758. GM_xmlhttpRequest({
  759. 'method': 'GET',
  760. 'url': fillStr(url.newcard, { 'query': queryStr, 'callback': 'STK_' + dateStr() }),
  761. 'onload': withTry(function (resp) {
  762. var respJson = JSON.parse(resp.responseText.replace(/^try{[^{]*\(/, '').replace(/\)}catch\(e\){};$/, ''));
  763. var namecard = cewih('div', respJson.data);
  764. var avatar = namecard.querySelector('.name dt img').getAttribute('src');
  765. var name = namecard.querySelector('.name dd a[uid]').getAttribute('title');
  766. var uid = namecard.querySelector('.name dd a[uid]').getAttribute('uid');
  767. var data = { 'avatar': avatar, 'id': uid, 'name': name };
  768. nameCache[name] = idCache[uid] = data;
  769. done(true, data);
  770. }, done.bind(this, false)),
  771. 'onerror': function () { done(false); },
  772. });
  773. return queryStr;
  774. };
  775. var byId = function (id, onsucc, onerror) {
  776. if (idCache[id]) onsucc(idCache[id]);
  777. else request('id=' + id, onsucc, onerror);
  778. };
  779. var byName = function (name, onsucc, onerror) {
  780. if (nameCache[name]) onsucc(nameCache[name]);
  781. else request('name=' + encodeURIComponent(name), onsucc, onerror);
  782. };
  783. return { 'id': byId, 'name': byName };
  784. }());
  785.  
  786. // 过滤器管理器
  787. var filters = (function () {
  788. var list = [], preinit = true;
  789. // 添加到表格中
  790. var add = function (details) {
  791. list.push(details);
  792. if (!preinit) details.init();
  793. return details;
  794. };
  795. // 网页加载完毕时初始化
  796. var init = function () {
  797. list.forEach(function (x) { x.init(); });
  798. preinit = false;
  799. };
  800. var dialog = null;
  801. var lastTab = 0;
  802. var dialogTabs = function (list, inner, page) {
  803. var alist = Array.apply(Array, inner.querySelectorAll('.yawf-config-header a'));
  804. var llist = Array.apply(Array, inner.querySelectorAll('.yawf-config-body .yawf-config-layer'));
  805. var choseLList = function (i) {
  806. llist.forEach(function (l) { l.style.display = 'none'; l.innerHTML = ''; });
  807. alist.forEach(function (a) { a.classList.remove('current'); a.classList.remove('S_bg5'); a.classList.add('S_bg1'); });
  808. llist[i].innerHTML = ''; list[i].show(llist[i]); llist[i].style.display = 'block';
  809. alist[i].classList.add('current'); alist[i].classList.remove('S_bg1'); alist[i].classList.add('S_bg5');
  810. lastTab = i;
  811. };
  812. list.map(function (filter, i) {
  813. var a = alist[i];
  814. a.addEventListener('mousedown', function () { choseLList(i); });
  815. a.addEventListener('keydown', function () { choseLList(i); });
  816. });
  817. choseLList(page);
  818. };
  819. var showDialog = function (page, count) {
  820. var showDialogInner = function (inner) {
  821. inner.innerHTML = [html.configHeaderTop,
  822. list.map(function (filter, index) {
  823. return fillStr(html.configHeaderItem, {
  824. 'name': text[filter.name + 'Title'],
  825. 'aclass': index === 0 ? 'S_bg5 current' : 'S_bg1',
  826. 'liclass': index === list.length - 1 ? 'pftb_itm_lst' : ' ',
  827. });
  828. }).join(''),
  829. html.configHeaderBottom,
  830. html.configLayerTop,
  831. list.map(function (filter, index) {
  832. return fillStr(html.configLayerItem, {
  833. 'name': filter.name + 'Layer',
  834. });
  835. }).join(''),
  836. html.configLayerBottom,
  837. html.configFooter,
  838. ].join('');
  839. call(function () { dialog.show(0); });
  840. if (list.indexOf(page) === -1) dialogTabs(list, inner, lastTab);
  841. else dialogTabs(list, inner, list.indexOf(page));
  842. };
  843. if (!(dialog = Dialog('yawf-config', '{{configDialogTitle}}', showDialogInner))) {
  844. if (!count || count < 100) setTimeout(showDialog, 100, page, (count || 0) + 1);
  845. }
  846. };
  847. return {
  848. 'add': add,
  849. 'init': init,
  850. 'showDialog': showDialog,
  851. };
  852. }());
  853.  
  854. // 快速创建过滤器的对话框
  855. var fastFilterDialog = function (chose) {
  856. var dialogInner = function (inner) {
  857. inner.innerHTML = html.fastFilterHeader + html.fastFilterFooter;
  858. var items = inner.querySelector('#yawf-fast-filter-list');
  859. var checkboxList = chose.map(function (c) {
  860. var item = cewih('ul', html.fastFilterItem).firstChild;
  861. var inner = item.querySelector('.yawf-fastFilterItemInner');
  862. var checked = c.filter.desc(inner, c.val) !== false;
  863. var checkbox = item.querySelector('input[type="checkbox"], input[type="radio"]');
  864. checkbox.checked = checked;
  865. items.appendChild(item);
  866. return checkbox;
  867. });
  868. var selectList = Array.apply(Array, inner.querySelectorAll('select'));
  869. selectList.forEach(function (select) { select.value = 'blacklist'; });
  870. // 找到所有选择了的过滤器
  871. var allChecked = function () {
  872. var active = [];
  873. checkboxList.forEach(function (checkbox, i) {
  874. if (checkbox.checked)
  875. active.push({ 'chose': chose[i], 'action': selectList[i].value });
  876. });
  877. return active;
  878. };
  879. var updateOkButton = function () {
  880. if (allChecked().length) ok.classList.remove('W_btn_a_disable');
  881. else ok.classList.add('W_btn_a_disable');
  882. };
  883. var ok = inner.querySelector('[action-type="ok"]');
  884. ok.addEventListener('click', function () {
  885. var active = allChecked();
  886. if (!active.length) return null;
  887. active.forEach(function (act) {
  888. act.chose.filter.add(act.chose.val, act.action);
  889. });
  890. dialog.hide();
  891. });
  892. checkboxList.forEach(function (checkbox) {
  893. checkbox.addEventListener('change', updateOkButton);
  894. });
  895. updateOkButton();
  896. var cancel = inner.querySelector('[action-type="cancel"]');
  897. cancel.addEventListener('click', function () { dialog.hide(); });
  898. };
  899. var dialog = Dialog('yawf-drop-select', '{{fastCreateChoseTitle}}', dialogInner);
  900. return dialog;
  901. };
  902.  
  903. // 将文本、链接等拖拽到框内,快速创建过滤器
  904. var dropdown = (function () {
  905. var dropArea, content;
  906. var dropdownFilters = [];
  907. var got = function (element) {
  908. if (!element) return;
  909. // 忽略最外面套的em/strong
  910. if (element.tagName && element.firstChild === element.lastChild &&
  911. ['strong', 'em'].indexOf(element.tagName.toLowerCase()) !== -1)
  912. element = element.firstChild;
  913. debug('got %o', element);
  914. var chose = [];
  915. // 问所有过滤器是不是需要
  916. dropdownFilters.forEach(function (filter, i) { chose[i] = null; });
  917. dropdownFilters.forEach(function (filter, i) {
  918. filter.valid(element, function (val) {
  919. if (!val) chose[i] = [];
  920. else if (val.constructor !== Array) chose[i] = [{ 'filter': filter, 'val': val }];
  921. else chose[i] = val.map(function (val) { return { 'filter': filter, 'val': val }; });
  922. if (chose.filter(function (x) { return !x; }).length) return;
  923. var chosen = chose.reduce(function (x, y) { return x.concat(y); });
  924. if (chosen.length) {
  925. var dialog = fastFilterDialog(chosen);
  926. call(function () { dialog.show(); });
  927. }
  928. });
  929. });
  930. };
  931. var init = function () {
  932. // 拖放到的框
  933. dropArea = cewih('div', html.dropArea).firstChild;
  934. var active = false, target = null;
  935. content = dropArea.querySelector('#yawf-drop-area-content');
  936. document.body.appendChild(dropArea);
  937. var hideDropArea = function () {
  938. if (target && target.hover) target.hover(); target = null;
  939. dropArea.style.display = 'none';
  940. };
  941. // 只接受从微博拽过来的东西
  942. var checkTarget = function () {
  943. var checker = target;
  944. for (; checker && checker !== document; checker = checker.parentNode) {
  945. if (!checker.classList || !checker.classList.contains || !checker.tagName) continue;
  946. if (checker.classList.contains('WB_feed')) return true;
  947. if (checker.classList.contains('W_miniblog')) return false;
  948. if (checker.tagName.toLowerCase() === 'body') return true;
  949. }
  950. return false;
  951. };
  952. // 开始拽
  953. document.addEventListener('dragstart', function (e) {
  954. var cover = document.querySelector('body>div[node-type="outer"]');
  955. if (cover && cover.clientHeight) return;
  956. target = e.explicitOriginalTarget; if (!target || !checkTarget()) return;
  957. active = true;
  958. dropArea.style.display = 'block';
  959. }, false);
  960. // 拽完了
  961. document.addEventListener('dragend', function (e) {
  962. if (!active) return; active = false;
  963. e.preventDefault(); e.stopPropagation();
  964. if (content.firstChild === content.lastChild) got(content.firstChild);
  965. else got(content);
  966. content.innerHTML = '';
  967. hideDropArea();
  968. }, false);
  969. // 拽出去了
  970. document.addEventListener('mouseout', function (e) {
  971. if (!active) return; active = false;
  972. hideDropArea();
  973. });
  974. };
  975. var add = function (details) {
  976. dropdownFilters.push(details);
  977. };
  978. return {
  979. 'init': init,
  980. 'add': add,
  981. };
  982. }());
  983.  
  984. // 告诉服务器屏蔽被隐藏的微博
  985. var blockWeibo = (function () {
  986. var buffer = [], busy = false;
  987. var delay = function () { return 3000 + Math.round(20 * Math.random()) * 100; };
  988. var block = function (mid, callback) {
  989. var done = function () { setTimeout(callback, delay()); };
  990. debug('blocking weibo %s', mid);
  991. GM_xmlhttpRequest({
  992. 'method': 'POST',
  993. 'url': fillStr(url.block_wb, { 'rnd': dateStr() }),
  994. 'headers': {
  995. 'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
  996. 'Cache-Control': 'no-cache',
  997. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
  998. 'Cookie': document.cookie,
  999. 'Referer': location.href,
  1000. 'X-Requested-With': 'XMLHttpRequest',
  1001. },
  1002. 'data': 'filter_type=0&mid=' + mid + '&justhide=0&location=home&_t=0',
  1003. 'onload': function (resp) { debug('block %s response: %s', mid, resp.responseText); done(); },
  1004. 'onerror': function () { debug('block %s network error', mid); done(); },
  1005. });
  1006. };
  1007. var active = function () {
  1008. if (!(busy = !!buffer.length)) return;
  1009. var mid = buffer.shift();
  1010. block(mid, active);
  1011. };
  1012. return function (mid) {
  1013. buffer.push(mid);
  1014. if (!busy) active();
  1015. return mid;
  1016. };
  1017. }());
  1018.  
  1019. // 有新节点时分发事件监听
  1020. var newNode = (function () {
  1021. var callbacks = [], actived = false;
  1022. var callAll = function (mutation) {
  1023. callbacks.forEach(function (c) { c(mutation); });
  1024. };
  1025. var observe = function () {
  1026. callAll(); // 初始化
  1027. (new MutationObserver(function (mutations) {
  1028. mutations.forEach(function (mutation) { callAll(mutation); });
  1029. })).observe(document.body, { 'childList': true, 'subtree': true });
  1030. };
  1031. var add = function (callback) {
  1032. callbacks.push(withTry(callback));
  1033. return callback;
  1034. };
  1035. var remove = function (callback) {
  1036. var found = false;
  1037. callbacks = callbacks.filter(function (x) {
  1038. var same = x === callback;
  1039. if (same) found = true;
  1040. return !same;
  1041. });
  1042. return found;
  1043. };
  1044. var active = function () {
  1045. if (actived) return;
  1046. actived = true;
  1047. observe();
  1048. };
  1049. return {
  1050. 'add': add,
  1051. 'remove': remove,
  1052. 'active': active,
  1053. };
  1054. }());
  1055.  
  1056. // 添加点击后展开折叠消息的事件
  1057. var fixFoldWeibo = (function () {
  1058. var fixOne = withTry(function (feed) {
  1059. var display = feed.getAttribute('yawf-display').replace(/-fold$/g, '-unfold');
  1060. var showFeed = function () {
  1061. feed.setAttribute('yawf-display', display);
  1062. feed.removeEventListener('click', showFeed);
  1063. };
  1064. var author = feed.querySelector('.WB_name[usercard]').getAttribute('title');
  1065. feed.setAttribute('yawf-author', author);
  1066. feed.addEventListener('click', showFeed);
  1067. });
  1068. var fix = function (feed) {
  1069. var feeds = [feed].concat(Array.apply(Array, feed.querySelectorAll('.WB_feed_type')));
  1070. feeds.forEach(function (feed) {
  1071. if (feed.getAttribute('yawf-display').lastIndexOf('-fold') === -1) return;
  1072. if (feed.getAttribute('yawf-author')) return;
  1073. fixOne(feed);
  1074. });
  1075. };
  1076. fix.init = function () {
  1077. css.add(fillStr('[node-type="feed_list"] .WB_feed_type[yawf-display$="-fold"]::before { content: {{foldedWeiboText}}; }'));
  1078. };
  1079. return fix;
  1080. }());
  1081.  
  1082. // 将父微博和下面的子微博交换
  1083. var swapParentSonWeibo = function (parent, son) {
  1084. var x = cewih('div', '');
  1085. ['.WB_face', '.WB_info', '.WB_text', '.WB_func'].map(function (q) {
  1086. (function (a, b) {
  1087. b.parentNode.replaceChild(x, b);
  1088. a.parentNode.replaceChild(b, a);
  1089. x.parentNode.replaceChild(a, x);
  1090. }(parent.querySelector(q), son.querySelector(q)));
  1091. });
  1092. var mid = parent.getAttribute('mid');
  1093. parent.setAttribute('mid', son.getAttribute('mid'));
  1094. son.setAttribute('mid', mid);
  1095. // 各种细节的修补(原网站做的太乱了……)
  1096. var pf = parent.querySelector('.WB_face'), sf = son.querySelector('.WB_face');
  1097. var pfa = pf.querySelector('a'), pfi = pf.querySelector('img');
  1098. var sfa = sf.querySelector('a'), sfi = sf.querySelector('img');
  1099. if (pfa.href.indexOf('?') === -1) pfa.href += '?from=feed&loc=avatar';
  1100. if (sfa.href.indexOf('?') !== -1) sfa.href = sfa.href.slice(0, sfa.href.indexOf('?'));
  1101. if (!pfa.title) pfa.title = pfi.title;
  1102. if (sfa.title) sfa.removeAttribute('title');
  1103. sfi.width = sfi.height = '30'; pfi.width = pfi.height = '50';
  1104. return son;
  1105. };
  1106.  
  1107. // 如果有一个微博的子微博都隐藏了,那么就隐藏这个微博的子微博框
  1108. var fixSonWeiboDisplay = function (feed) {
  1109. if (!feed.querySelector('.WB_feed_together')) return fixFoldWeibo(feed);
  1110. var sonList = Array.apply(Array, feed.querySelectorAll('.WB_feed_together .WB_sonFeed .WB_feed_type[yawf-display]'));
  1111. // 交换两个子微博
  1112. var swapSon = function (p, q) {
  1113. var x = sonList[p], y = sonList[q];
  1114. var fakeNode = document.createElement('div');
  1115. x.parentNode.insertBefore(fakeNode, x);
  1116. y.parentNode.insertBefore(x, y);
  1117. fakeNode.parentNode.insertBefore(y, fakeNode);
  1118. fakeNode.parentNode.removeChild(fakeNode);
  1119. sonList[p] = y; sonList[q] = x;
  1120. };
  1121. // 把子微博重新排序一下,按照从想看到不想看的顺序排列,排序算法和一趟快排差不多
  1122. var p = 0, q;
  1123. ['show', 'unset', 'unfold', 'fold', 'hidden'].forEach(function (display) {
  1124. q = sonList.length - 1;
  1125. while (p < q) {
  1126. if (sonList[p].getAttribute('yawf-display').lastIndexOf(display) !== -1) p++;
  1127. else if (sonList[q].getAttribute('yawf-display').lastIndexOf(display) === -1) q--;
  1128. else swapSon(p, q);
  1129. }
  1130. });
  1131. // 看看还有多少显示出来的子微博,更新一下子微博的计数
  1132. var sonCount = feed.querySelectorAll('.WB_feed_together .WB_sonFeed .WB_feed_type:not([yawf-display$="-hidden"])').length;
  1133. if (sonCount === 0) feed.querySelector('.WB_feed_together').setAttribute('yawf-display', 'display-hidden');
  1134. else feed.querySelector('[node-type="followNum"]').textContent = sonCount;
  1135. // 如果下面更多的按钮已经没用了,就藏起来吧
  1136. var foldSonCount = feed.querySelectorAll('[node-type="feed_list_wrapForward"] .WB_feed_type:not([yawf-display$="-hidden"])').length;
  1137. if (foldSonCount === 0 && feed.querySelector('[node-type="feed_list_wrapForward"]')) {
  1138. feed.querySelector('.WB_feed_together').setAttribute('yawf-sonfold', 'display');
  1139. }
  1140. // 把原始微博和子微博拆开
  1141. var another = feed.cloneNode(true);
  1142. feed.parentNode.insertBefore(another, feed.nextSibling);
  1143. feed.setAttribute('yawf-withson', 'son');
  1144. another.setAttribute('yawf-display', 'display-son');
  1145. fixFoldWeibo(feed);
  1146. fixFoldWeibo(another);
  1147. };
  1148.  
  1149. // 真正微博过滤的核心模块
  1150. var weiboFilter = function (feed) {
  1151. // 同源合并的微博
  1152. var sonFeeds = Array.apply(Array, feed.querySelectorAll('[node-type="feed_list"] .WB_feed_type:not([yawf-display])'));
  1153. var action = null, parentAction = null;
  1154. var needSwap = function (action) {
  1155. if (!sonFeeds.length) return false;
  1156. if (['hidden', 'fold'].indexOf(action) === -1) return false;
  1157. return true;
  1158. };
  1159. var setAction = function (feed, action) {
  1160. feed.setAttribute('yawf-display', 'display-' + action);
  1161. };
  1162. while (true) {
  1163. action = rules.parse(feed) || 'unset';
  1164. // 如果父微博被屏蔽或折叠,那么就把下面一条没被屏蔽的拉上来换个位置
  1165. if (!needSwap(action)) break;
  1166. setAction(swapParentSonWeibo(feed, sonFeeds.pop()), action);
  1167. }
  1168. parentAction = action;
  1169. // 最后处理所有下面的子微博
  1170. var fixSonWeibo = function (son) {
  1171. var action = rules.parse(son) || 'unset';
  1172. setAction(son, action);
  1173. // 如果一列里面有白名单的,那么把白名单的特别换到外面去
  1174. if (parentAction !== 'show' && action === 'show') {
  1175. setAction(swapParentSonWeibo(feed, son), parentAction);
  1176. parentAction = action;
  1177. }
  1178. };
  1179. while (sonFeeds.length) fixSonWeibo(sonFeeds.shift());
  1180. setAction(feed, parentAction);
  1181. fixSonWeiboDisplay(feed);
  1182. };
  1183.  
  1184. // 对每条微博应用过滤和其他相关回调
  1185. var eachWeibo = (function () {
  1186. var befores = [], afters = [];
  1187. newNode.add(function () {
  1188. var feeds = Array.apply(Array,
  1189. document.querySelectorAll('[node-type="feed_list"] .WB_feed_type:not([yawf-display])'));
  1190. [befores, [weiboFilter], afters].forEach(function (callbacks) {
  1191. feeds.forEach(function (feed) {
  1192. callbacks.forEach(function (f) { f(feed); });
  1193. });
  1194. });
  1195. });
  1196. var add = function (callbacks) {
  1197. return function (callback) {
  1198. callbacks.push(withTry(callback));
  1199. return callback;
  1200. };
  1201. };
  1202. return {
  1203. 'before': add(befores),
  1204. 'after': add(afters),
  1205. };
  1206. }());
  1207.  
  1208. // 根据选择类型不同生成一些存取设置的函数
  1209. var typedConfig = (function () {
  1210. // 字符串
  1211. var baseConfig = function (type) {
  1212. return function (item) {
  1213. var skey = item.key;
  1214. if (item.internal) skey = skey.replace(/\.([^\.]*)$/, '._$1');
  1215. if (!item.getconf) item.getconf = function () {
  1216. return item.conf = config.get(skey, item['default'] || type(), type);
  1217. };
  1218. if (!item.putconf) item.putconf = function (conf) {
  1219. return config.put(skey, item.conf = conf);
  1220. };
  1221. config.reg(skey);
  1222. return item.putconf(item.getconf());
  1223. };
  1224. };
  1225. // 集合类型的add/del操作
  1226. var itemsConfig = function (item) {
  1227. var value = baseConfig(Array)(item);
  1228. if (!item.delconf) item.delconf = function (str) {
  1229. var val = item.getconf();
  1230. val = val.filter(function (x) { return x !== str; });
  1231. return item.putconf(val);
  1232. };
  1233. if (!item.addconf) item.addconf = function (str) {
  1234. item.delconf(str);
  1235. var val = item.getconf(); val.push(str);
  1236. return item.putconf(val);
  1237. };
  1238. return value;
  1239. };
  1240. return {
  1241. 'string': baseConfig(String),
  1242. 'strings': itemsConfig,
  1243. 'boolean': baseConfig(Boolean),
  1244. 'users': itemsConfig,
  1245. 'number': baseConfig(Number),
  1246. 'range': baseConfig(Number),
  1247. 'select': baseConfig(String),
  1248. 'color': baseConfig(String),
  1249. 'key': baseConfig(Number),
  1250. };
  1251. }());
  1252.  
  1253. // 将输入框和某个设置项绑定
  1254. var bindInputValue = (function () {
  1255. var bind = function (key, input, obj, standlize) {
  1256. var fine = standlize || function (x) { return x; };
  1257. var onchange = function () {
  1258. var val = input[key], valid;
  1259. valid = fine(val);
  1260. if (String(valid) !== val) input[key] = valid;
  1261. obj.putconf(valid);
  1262. };
  1263. input[key] = fine(obj.getconf());
  1264. input.addEventListener('change', onchange);
  1265. return onchange;
  1266. };
  1267. return {
  1268. 'text': bind.bind(null, 'value'),
  1269. 'checkbox': bind.bind(null, 'checked'),
  1270. 'select': bind.bind(null, 'value'),
  1271. };
  1272. }());
  1273.  
  1274. // 根据不同类型生成带有事件的文档节点
  1275. var typedHtml = (function () {
  1276.  
  1277. var base = function (base, binder) {
  1278. return function () {
  1279. var item = this;
  1280. // 引用的设置项
  1281. var ref = item.ref;
  1282. // 显示的文字
  1283. var inp = '{{}}', outer = inp, inner = '', text;
  1284. var hasInput = !!html['config' + base + 'Input'];
  1285. if (!item.nogui) {
  1286. text = fillStr(item.text || '').replace(/\|\|/g, html['||']).replace(/\|/g, html['|']);
  1287. if (hasInput && text.indexOf(inp) === -1) text = inp + text;
  1288. outer = fillStr(html['config' + base], { 'text': text }, item);
  1289. }
  1290. if (hasInput) inner = fillStr(html['config' + base + 'Input'], item);
  1291. var line = outer.replace(inp, inner);
  1292. // 在需要引用其他控件的地方留空
  1293. if (!item.nogui) line = line.replace(/{{<([a-zA-Z0-9_-]*)>}}/g, function (m, p) {
  1294. return ref[p] ? fillStr(html.configPrefill, { 'id': p }) : m;
  1295. });
  1296. // 构造基本的文档
  1297. var dom = cewih('div', line).firstChild;
  1298. // 将引用的设置控件填回
  1299. var pf = Array.apply(Array, dom.querySelectorAll('span.yawf-configPrefill'));
  1300. pf.forEach(function (pfi) {
  1301. pfi.parentNode.replaceChild(ref[pfi.id].show(), pfi);
  1302. });
  1303. if (binder) binder(dom, item);
  1304. return dom;
  1305. };
  1306. };
  1307.  
  1308. // 副标题
  1309. var subtitle = base('Subtitle');
  1310. // 文本
  1311. var text = base('Text');
  1312. // 不缩进的文本
  1313. var remark = base('Remark');
  1314.  
  1315. // 真假值的设置项
  1316. var boolean = base('Boolean', function (dom, item) {
  1317. bindInputValue.checkbox(dom.querySelector('input'), item);
  1318. });
  1319.  
  1320. // 选择框设置项
  1321. var select = base('Select', function (dom, item) {
  1322. var select = dom.querySelector('select');
  1323. var defaultValue = item['default'] || item.select.key;
  1324. var keys = item.select.map(function (option) {
  1325. select.appendChild(cewih('select', fillStr(html.option, option)).firstChild);
  1326. return option.value;
  1327. });
  1328. bindInputValue.select(select, item, function (val) {
  1329. return keys.indexOf(val) === -1 ? defaultValue : val;
  1330. });
  1331. });
  1332.  
  1333. // 字符串的设置项
  1334. var string = base('String', function (dom, item) {
  1335. var textarea = dom.querySelector('textarea');
  1336. var onchange = bindInputValue.text(textarea, item);
  1337. textarea.addEventListener('keyup', function () {
  1338. call(onchange);
  1339. });
  1340. });
  1341.  
  1342. // 颜色的设置项
  1343. var color = base('Color', function (dom, item) {
  1344. bindInputValue.text(dom.querySelector('input'), item);
  1345. });
  1346.  
  1347. // 数字的设置项
  1348. var number = base('Number', function (dom, item) {
  1349. var number = dom.querySelector('input');
  1350. var max = Infinity, min = -Infinity;
  1351. if ('max' in item) max = item.max;
  1352. if ('min' in item) min = item.min;
  1353. if (min > max) min = max;
  1354. number.min = min; number.max = max;
  1355. bindInputValue.text(number, item, function (val) {
  1356. if (isNaN(Number(val))) return val = 0;
  1357. return Math.min(max, Math.max(min, Number(val)));
  1358. });
  1359. });
  1360.  
  1361. // 字符串数组设置项模板
  1362. var items = function (base, genli) {
  1363. var item = this;
  1364. var dom = cewih('div', fillStr(base, item)).firstChild;
  1365. var form = dom.querySelector('form'), input = dom.querySelector('input'), ul = dom.querySelector('ul');
  1366. var shown = {};
  1367. // 将某个已经有的字符串显示到末尾
  1368. var moveToEnd = function (x) {
  1369. var p = x.parentNode; p.appendChild(p.removeChild(x));
  1370. };
  1371. // 显示一个新的字符串
  1372. var showStrings = function (userinput, str, onsucc, ondone) {
  1373. genli(item, userinput, str, function (str, li) {
  1374. if (ondone) ondone();
  1375. if (!str || !li) return;
  1376. if (shown[str]) return moveToEnd(shown[str]);
  1377. var del = li.querySelector('a.icon_close');
  1378. del.addEventListener('click', function () {
  1379. delete shown[str];
  1380. if (item.del) item.del(str);
  1381. li.parentNode.removeChild(li);
  1382. item.delconf(str);
  1383. });
  1384. ul.appendChild(shown[str] = li);
  1385. if (onsucc) onsucc(str);
  1386. });
  1387. };
  1388. item.getconf().forEach(function (str) { showStrings(false, str); });
  1389. form.addEventListener('submit', function (e) {
  1390. e.preventDefault();
  1391. var str = input.value;
  1392. input.disabled = true;
  1393. showStrings(true, str, function (str) {
  1394. if (item.add) item.add(str);
  1395. item.addconf(str);
  1396. }, function () {
  1397. input.value = '';
  1398. input.disabled = false;
  1399. });
  1400. });
  1401. return dom;
  1402. };
  1403.  
  1404. // 字符串设置项
  1405. var strings = function () {
  1406. return items.call(this, html.configStrings, function (item, userinput, str, callback) {
  1407. if (userinput && item.add && !(str = item.add(str))) callback();
  1408. else callback(str, cewih('ul', fillStr(html.configStringsItem, { 'item': item.display ? item.display(str) : str })).firstChild);
  1409. });
  1410. };
  1411.  
  1412. // 用户列表的设置项
  1413. var users = function () {
  1414. return items.call(this, html.configUsers, function (item, userinput, str, callback) {
  1415. var showUserNotExistError = function () {
  1416. Alert('yawf-user-not-exist', {
  1417. 'title': fillStr('{{accountNotExistErrorTitle}}'),
  1418. 'text': fillStr('{{{accountNotExistError}}}', { 'name': escapeXml(str) }),
  1419. 'icon': 'error'
  1420. });
  1421. callback();
  1422. };
  1423. if (userinput) {
  1424. if (!(str = str.trim().replace(/^@/, ''))) return callback();
  1425. account.name(str, function (info) {
  1426. if (!info) showUserNotExistError();
  1427. else if (item.add && !item.add(info)) callback();
  1428. else callback(info.id, cewih('ul', fillStr(html.configUsersItem, info)).firstChild);
  1429. }, showUserNotExistError);
  1430. } else {
  1431. var emptyInfo = { 'id': str, 'name': ' ', 'avatar': ' ' };
  1432. var li = cewih('ul', fillStr(html.configUsersItem, emptyInfo)).firstChild;
  1433. callback(str, li);
  1434. account.id(str, function (info) {
  1435. var u = li.querySelector('[uid]');
  1436. u.setAttribute('uid', info.id); u.setAttribute('title', info.name); u.textContent = info.name;
  1437. var p = li.querySelector('.pic img');
  1438. p.src = info.avatar;
  1439. });
  1440. }
  1441. });
  1442. };
  1443.  
  1444. // 一个有数字和垂直范围条的输入框
  1445. var range = base('Range', function (dom, item) {
  1446. var n = dom.querySelector('input[type="number"]');
  1447. var r = dom.querySelector('input[type="range"]');
  1448. n.max = item.max; r.max = item.max;
  1449. n.min = item.min; r.min = item.min;
  1450. var onchange = bindInputValue.text(n, item, function (val) {
  1451. if (isNaN(parseInt(val))) return item['default'] || item.min;
  1452. return Math.min(Math.max(parseInt(val), item.min), item.max);
  1453. });
  1454. r.value = n.value;
  1455. var updateN = function () { if (r.value !== n.value) n.value = r.value; onchange(); };
  1456. var updateR = function () { if (r.value !== n.value) r.value = n.value; onchange(); };
  1457. r.addEventListener('change', updateN); r.addEventListener('mousemove', updateN);
  1458. n.addEventListener('change', updateR); n.addEventListener('keypress', updateR);
  1459. });
  1460.  
  1461. // 一个输入按键的输入框
  1462. var key = base('Key', function (dom, item) {
  1463. var i = dom.querySelector('input'), s = dom.querySelector('button');
  1464. var copyName = function () { s.textContent = keys.name(Number(i.value)); };
  1465. var eventClear = function (e) { e.stopPropagation(); e.preventDefault(); };
  1466. var valid = function (key) { if (key === 27) return 0; return key; }
  1467. var onchange = bindInputValue.text(i, item, function (val) {
  1468. call(copyName); return Number(val);
  1469. });
  1470. dom.addEventListener('keydown', function (e) {
  1471. var val = valid(keys.get(e));
  1472. i.value = val;
  1473. copyName();
  1474. onchange();
  1475. eventClear(e);
  1476. }, false);
  1477. dom.addEventListener('keyup', eventClear, false);
  1478. dom.addEventListener('keypress', eventClear, false);
  1479. i.addEventListener('change', copyName);
  1480. call(copyName);
  1481. });
  1482.  
  1483. return {
  1484. 'subtitle': subtitle,
  1485. 'text': text,
  1486. 'remark': remark,
  1487. 'string': string,
  1488. 'color': color,
  1489. 'number': number,
  1490. 'select': select,
  1491. 'strings': strings,
  1492. 'boolean': boolean,
  1493. 'users': users,
  1494. 'range': range,
  1495. 'key': key,
  1496. };
  1497. }());
  1498.  
  1499. // 过滤器组
  1500. var filterGroup = function (groupName) {
  1501. var items = [];
  1502. // 向过滤器组里面添加一个项目
  1503. var add = function (item) {
  1504. // 先加入所有被引用的对象
  1505. if (item.ref) Object.keys(item.ref).forEach(function (key) {
  1506. item.ref[key].key = item.key + '.' + key;
  1507. item.ref[key].nogui = true;
  1508. add(item.ref[key]);
  1509. });
  1510. // 再加入自己
  1511. items.push(item);
  1512. return item;
  1513. };
  1514. // 网页被初始化时初始化所有过滤器
  1515. var init = function () {
  1516. items.forEach(withTry(function (item) {
  1517. // 初始化过滤器的设置
  1518. if (item.type && typedConfig[item.type])
  1519. item.conf = typedConfig[item.type](item);
  1520. // 初始化过滤器的显示
  1521. if (!item.show && item.type && typedHtml[item.type])
  1522. item.show = typedHtml[item.type].bind(item);
  1523. // 过滤器自己的初始化
  1524. if (item.init) item.init();
  1525. // 真假设置项若设置激活时调用
  1526. if (item.type === 'boolean' && item.conf && item.ainit) item.ainit();
  1527. // 将规则加入到列表中
  1528. if (item.rule) rules.add(item.priority || 0, item.rule.bind(item));
  1529. }));
  1530. };
  1531. // 需要显示选项时生成界面
  1532. var show = function (inner) {
  1533. items.forEach(withTry(function (item) {
  1534. var dom = null;
  1535. if (item.show) dom = item.show(dom);
  1536. if (dom) {
  1537. if (item.shown) item.shown(dom);
  1538. if (!item.nogui) inner.appendChild(dom);
  1539. }
  1540. }));
  1541. };
  1542. // 注册到过滤器分组
  1543. var group = {
  1544. 'name': groupName,
  1545. 'show': show,
  1546. 'init': init,
  1547. 'add': add
  1548. };
  1549. return filters.add(group);
  1550. };
  1551.  
  1552. // 把后面的对象的元素加到第一个上面去
  1553. var extend = function (obj1) {
  1554. return Array.apply(Array, arguments).reduce(function (x, y) {
  1555. for (var k in y) x[k] = y[k];
  1556. return x;
  1557. });
  1558. };
  1559.  
  1560. // 当前是查看分组的页面吗?
  1561. var onGroupPage = function () {
  1562. return location.pathname.slice(-9) === '/mygroups';
  1563. };
  1564.  
  1565. // 白名单、黑名单和折叠名单一式三份
  1566. var allInOneFilters = function (details) {
  1567. var filters = [
  1568. { 'type': 'whitelist', 'priority': 1e5, 'action': 'show' },
  1569. { 'type': 'blacklist', 'priority': 0, 'action': 'hidden' },
  1570. { 'type': 'foldlist', 'priority': -1e5, 'action': 'fold' },
  1571. ];
  1572. var rules = {};
  1573. var typedFilterGroup = filterGroup(details.name + 'FilterGroup');
  1574. filters.forEach(function (filter) {
  1575. // 标题
  1576. typedFilterGroup.add({
  1577. 'type': 'subtitle',
  1578. 'text': '{{{' + filter.type + 'FilterDesc}}}',
  1579. 'typed': '{{' + details.name + 'FilterDetails}}',
  1580. 'shown': function (dom) {
  1581. dom.classList.add('yawf-' + filter.type + 'FilterTitle');
  1582. },
  1583. });
  1584. // 过滤器
  1585. var rule = {
  1586. 'type': details.type || 'strings',
  1587. 'key': 'weibo.filters.' + details.name + '.' + filter.type,
  1588. 'priority': filter.priority,
  1589. 'text': '{{' + details.name + 'FilterDesc}}',
  1590. };
  1591. if (details.add) rule.add = details.add.bind(rule);
  1592. if (details.display) rule.display = details.display.bind(rule);
  1593. rule.rule = details.rule.bind(rule, filter.action);
  1594. if (details[filter.type]) {
  1595. Object.keys(details[filter.type]).forEach(function (override) {
  1596. rule[override] = details[filter.type][override](rule[override]);
  1597. });
  1598. }
  1599. rules[filter.type] = typedFilterGroup.add(rule);
  1600. });
  1601. // 快速创建过滤器的拖动
  1602. if (details.fast) {
  1603. dropdown.add({
  1604. 'valid': details.fast.valid,
  1605. 'desc': details.fast.desc,
  1606. 'add': function (val, action) {
  1607. var value = details.fast.add(val);
  1608. if (details.add) value = details.add(value);
  1609. rules[action].addconf(value);
  1610. },
  1611. });
  1612. }
  1613. return typedFilterGroup;
  1614. };
  1615.  
  1616. // 方便的选择器
  1617. var weiboContentSelector = function (feed, f) {
  1618. var content = feed.querySelector('[node-type="feed_list_content"]');
  1619. var reason = feed.querySelector('[node-type="feed_list_reason"] em');
  1620. var items = [];
  1621. if (content) items = items.concat(Array.apply(Array, f(content)));
  1622. if (reason) items = items.concat(Array.apply(Array, f(reason)));
  1623. return items;
  1624. };
  1625.  
  1626. var validKeywordItem = function (wrap) {
  1627. wrap = wrap || function (x) { return x; };
  1628. return function (element, callback) {
  1629. var valid = false;
  1630. if (element.nodeType === Node.TEXT_NODE) valid = true;
  1631. else if ((element.tagName || '').toLowerCase() === 'em' &&
  1632. element.firstChild === element.lastChild &&
  1633. element.firstChild.nodeType === Node.TEXT_NODE) valid = true;
  1634. if (valid) callback({ 'text': wrap(element.textContent) }); else callback();
  1635. };
  1636. };
  1637.  
  1638. var keywordOrRegexFastDesc = function (type) {
  1639. return function (dom, val) {
  1640. dom.innerHTML = fillStr('{{{' + type + 'FilterFast}}}');
  1641. var labelc = cewih('div', html.fastFilterString).firstChild;
  1642. labelc.querySelector('span').innerHTML = fillStr('{{{' + type + 'FilterFastInput}}}', { 'text': html.fastFilterStringInput });
  1643. var input = labelc.querySelector('input'); input.value = val.text;
  1644. var ref = dom.parentNode; ref.parentNode.insertBefore(labelc, ref.nextSibling);
  1645. input.addEventListener('change', function () { val.text = input.value; });
  1646. var checkbox = ref.parentNode.querySelector('input[type=checkbox]');
  1647. checkbox.type = 'radio'; checkbox.name = 'yawfKeywordOrRegexp';
  1648. return type === 'keyword';
  1649. };
  1650. };
  1651.  
  1652. // 关键字过滤
  1653. var keywordFilterGroup = allInOneFilters({
  1654. 'name': 'keyword',
  1655. 'add': function (s) { return s.trim(); },
  1656. 'rule': function keywordMatch(action, feed) {
  1657. var keywords = this.conf;
  1658. var texts = weiboContentSelector(feed, function (m) {
  1659. return Array.apply(Array, m.childNodes)
  1660. .filter(function (node) { return node.nodeType === Node.TEXT_NODE; })
  1661. .map(function (node) { return node.textContent; });
  1662. }).join(' ').toUpperCase();
  1663. var match = keywords.some(function (keyword) {
  1664. if (!keyword) return false;
  1665. return texts.indexOf(keyword.toUpperCase()) !== -1;
  1666. });
  1667. if (match) return action; else return null;
  1668. },
  1669. 'fast': {
  1670. 'valid': validKeywordItem(),
  1671. 'desc': keywordOrRegexFastDesc('keyword'),
  1672. 'add': function (val) { return val.text; },
  1673. }
  1674. });
  1675.  
  1676. // 按照正则式过滤
  1677. var regexpFilterGroup = allInOneFilters({
  1678. 'name': 'regexp',
  1679. 'add': function (s) {
  1680. s = s.trim();
  1681. if (s[0] === '/' && s[s.length - 1] === '/') s = s.slice(1, -1);
  1682. try { RegExp(s).exec(''); } catch (e) {
  1683. Alert('yawf-regexp-bad-formed', {
  1684. 'title': fillStr('{{regexpBadFormedTitle}}'),
  1685. 'text': fillStr('{{{regexpBadFormed}}}', { 'regexp': escapeXml(s) }),
  1686. 'icon': 'error'
  1687. });
  1688. s = null;
  1689. }
  1690. return s;
  1691. },
  1692. 'display': function (s) { return '/' + s + '/'; },
  1693. 'rule': function regexpMatch(action, feed) {
  1694. if (!this.regexen) this.regexen = this.conf.map(function (s) {
  1695. try { return RegExp(s); }
  1696. catch (e) { debug('erorr while compile regexp %s : %o', s, e); }
  1697. }).filter(function (x) { return x; });
  1698. var regexen = this.regexen;
  1699. var texts = weiboContentSelector(feed, function (m) {
  1700. return Array.apply(Array, m.childNodes)
  1701. .filter(function (node) { return node.nodeType === Node.TEXT_NODE; })
  1702. .map(function (node) { return node.textContent; });
  1703. }).join(' ');
  1704. var match = regexen.some(function (regexp) {
  1705. return !!(regexp.exec(texts));
  1706. });
  1707. if (match) return action; else return null;
  1708. },
  1709. 'fast': {
  1710. 'valid': validKeywordItem(function (s) {
  1711. return s.replace(/([.*+?^${}()|\[\]\/\\])/g, "\\$1");
  1712. }),
  1713. 'desc': keywordOrRegexFastDesc('regexp'),
  1714. 'add': function (val) { return val.text; },
  1715. }
  1716. });
  1717.  
  1718. // 关于正则式的说明
  1719. regexpFilterGroup.add({
  1720. 'type': 'text',
  1721. 'text': '{{regexpFilterRemark}}',
  1722. });
  1723.  
  1724. // 从一条微博中找到他的作者
  1725. var getFeedAuthorId = function (feed) {
  1726. var author = feed.querySelector('.WB_name[usercard]');
  1727. if (!author) return null;
  1728. return author.getAttribute('usercard').split('=')[1];
  1729. };
  1730.  
  1731. // 检查一个元素是不是用户相关的
  1732. var validUserElement = function (element, callback) {
  1733. if (element.nodeType === Node.TEXT_NODE) return callback();
  1734. var a = null;
  1735. // 作者或来源
  1736. try {
  1737. if (element.classList.contains('WB_name')) a = element;
  1738. else a = element.querySelector('.WB_name');
  1739. if (a && (a.getAttribute('usercard') || '').indexOf('id=') === 0) {
  1740. return callback({
  1741. 'name': a.getAttribute('title'),
  1742. 'id': a.getAttribute('usercard').slice(3),
  1743. });
  1744. }
  1745. } catch (e) { }
  1746. // 提及,别名
  1747. try {
  1748. if (element.getAttribute('usercard')) a = element;
  1749. else a = element.querySelector('[usercard]');
  1750. if (a && (a.getAttribute('usercard') || '').indexOf('name=') === 0) {
  1751. return account.name(a.getAttribute('usercard').slice(5), callback, callback);
  1752. }
  1753. if (a && (a.getAttribute('usercard') || '').indexOf('id=') === 0) {
  1754. return account.id(a.getAttribute('usercard').slice(3), callback, callback);
  1755. }
  1756. } catch (e) { }
  1757. // 其他
  1758. try {
  1759. if (element.getAttribute('title') && element.getAttribute('uid')) a = element;
  1760. else if (element.getAttribute('title') && element.getAttribute('usercard').indexOf('id=') === 0) a = element;
  1761. else a = element.querySelector('[title][uid], [title][usercard^="id="]');
  1762. if (a) {
  1763. return callback({
  1764. 'name': a.getAttribute('title'),
  1765. 'id': a.getAttribute('uid') || a.getAttribute('usercard').slice(3),
  1766. });
  1767. }
  1768. } catch (e) { }
  1769. callback();
  1770. };
  1771.  
  1772. // 作者用户过滤
  1773. var accountFilterGroup = allInOneFilters({
  1774. 'name': 'account',
  1775. 'type': 'users',
  1776. 'rule': function accountMatch(action, feed) {
  1777. var accounts = this.conf, id = getFeedAuthorId(feed);
  1778. if (!id) return null;
  1779. var match = accounts.some(function (x) { return x === id; });
  1780. if (match) return action; else return null;
  1781. },
  1782. 'blacklist': {
  1783. 'rule': function accountMatchBlacklistOverride(_super) {
  1784. return function accountMatchBlacklist(feed) {
  1785. if (!accountByGroup.conf || !onGroupPage()) return _super(feed);
  1786. return null;
  1787. };
  1788. },
  1789. },
  1790. 'fast': {
  1791. 'valid': validUserElement,
  1792. 'desc': function (dom, val) {
  1793. dom.innerHTML = fillStr('{{{accountFilterFast}}}', { 'name': escapeXml(val.name) });
  1794. return true;
  1795. },
  1796. 'add': function (val) { return val.id; },
  1797. },
  1798. });
  1799.  
  1800. accountFilterGroup.add({
  1801. 'type': 'text',
  1802. 'text': '{{accountFilterRemark}}',
  1803. });
  1804.  
  1805.  
  1806. // 从一条微博中找到他的作者
  1807. var getFeedOriginalId = function (feed) {
  1808. var originalAuthor = feed.querySelector('.WB_media_expand .WB_info .WB_name');
  1809. if (!originalAuthor) return null;
  1810. return originalAuthor.getAttribute('usercard').split('=')[1];
  1811. };
  1812.  
  1813. // 原创用户过滤
  1814. var originalFilterGroup = allInOneFilters({
  1815. 'name': 'original',
  1816. 'type': 'users',
  1817. 'rule': function originalMatch(action, feed) {
  1818. var originals = this.conf, id = getFeedOriginalId(feed);
  1819. if (!id) return null;
  1820. var match = originals.some(function (x) { return x === id; });
  1821. if (match) return action; else return null;
  1822. },
  1823. 'fast': {
  1824. 'valid': validUserElement,
  1825. 'desc': function (dom, val) {
  1826. dom.innerHTML = fillStr('{{{originalFilterFast}}}', { 'name': escapeXml(val.name) });
  1827. return true;
  1828. },
  1829. 'add': function (val) { return val.id; },
  1830. },
  1831. });
  1832.  
  1833. // 找到在一条微博里面被提到的人的昵称
  1834. var getFeedMentionList = function (feed) {
  1835. return weiboContentSelector(feed, function (m) {
  1836. return Array.apply(Array, m.querySelectorAll('a[usercard^="name="][href$="loc=at"]'));
  1837. }).map(function (link) {
  1838. return link.getAttribute('usercard').slice('name='.length);
  1839. });
  1840. };
  1841.  
  1842. // 提到某人的微博
  1843. var mentionFilterGroup = allInOneFilters({
  1844. 'name': 'mention',
  1845. 'type': 'strings',
  1846. 'add': function (s) { return s.trim().replace(/^@/, ''); },
  1847. 'display': function (s) { return '@' + s; },
  1848. 'rule': function mentionMatch(action, feed) {
  1849. var mentions = this.conf, users = getFeedMentionList(feed);
  1850. var match = users.some(function (name) {
  1851. return mentions.indexOf(name) !== -1;
  1852. });
  1853. if (match) return action; else return null;
  1854. },
  1855. 'fast': {
  1856. 'valid': validUserElement,
  1857. 'desc': function (dom, val) {
  1858. dom.innerHTML = fillStr('{{{mentionFilterFast}}}', { 'name': escapeXml(val.name) });
  1859. return true;
  1860. },
  1861. 'add': function (val) { return val.name; },
  1862. },
  1863. });
  1864.  
  1865. var getFeedTopicList = function (feed) {
  1866. return weiboContentSelector(feed, function (m) {
  1867. return Array.apply(Array, m.querySelectorAll('.a_topic'));
  1868. }).map(function (topic) { return topic.textContent; });
  1869. };
  1870.  
  1871. // 话题过滤
  1872. var topicFilterGroup = allInOneFilters({
  1873. 'name': 'topic',
  1874. 'add': function (s) { return s.trim().replace(/#/g, ''); },
  1875. 'display': function (s) { return '#' + s + '#'; },
  1876. 'rule': function topicMatch(action, feed) {
  1877. var topics = this.conf;
  1878. var text = getFeedTopicList(feed).join('##');
  1879. var match = topics.some(function (topic) { return text.indexOf(topic) !== -1; });
  1880. if (match) return action; else return null;
  1881. },
  1882. 'fast': {
  1883. 'valid': function (element, callback) {
  1884. var a = null;
  1885. if (element.nodeType === Node.TEXT_NODE) return callback();
  1886. try {
  1887. if (element.tagName.toLowerCase() === 'a' && element.classList.contains('a_topic')) a = element;
  1888. else a = element.querySelector('a.a_topic');
  1889. if (a) return callback({ 'topic': a.textContent.trim().replace(/#/g, '') });
  1890. } catch (e) { }
  1891. callback();
  1892. },
  1893. 'desc': function (dom, val) {
  1894. dom.innerHTML = fillStr('{{{topicFilterFast}}}', { 'topic': escapeXml(val.topic) });
  1895. return true;
  1896. },
  1897. 'add': function (val) { return val.topic; },
  1898. }
  1899. });
  1900.  
  1901. // 获取一条微博的所有来源(包括转发)
  1902. var getFeedSourceList = function (feed) {
  1903. return ['[node-type="feed_list_funcLink"] [action-type="app_source"]',
  1904. '.WB_media_expand [action-type="app_source"]'].map(function (qs) {
  1905. var st = feed.querySelector(qs); if (!st) return null;
  1906. return st.getAttribute('title') || st.textContent || '未通过审核应用';
  1907. }).filter(function (x) { return x; });
  1908. };
  1909.  
  1910. // 来源过滤
  1911. var sourceFilterGroup = allInOneFilters({
  1912. 'name': 'source',
  1913. 'add': function (s) {
  1914. s = s.trim();
  1915. if (s === '微博 weibo.com') {
  1916. Alert('yawf-source-filter-warning', {
  1917. 'title': fillStr('{{sourceFilterWarningTitle}}'),
  1918. 'text': fillStr('{{sourceFilterWarning}}'),
  1919. 'icon': 'error'
  1920. });
  1921. s = null;
  1922. }
  1923. return s;
  1924. },
  1925. 'rule': function sourceMatch(action, feed) {
  1926. var sources = this.conf, _sources = getFeedSourceList(feed);
  1927. var match = _sources.some(function (s) { return sources.indexOf(s) !== -1; });
  1928. if (match) return action; else return null;
  1929. },
  1930. 'fast': {
  1931. 'valid': function (element, callback) {
  1932. var a = null;
  1933. if (element.nodeType === Node.TEXT_NODE) return callback();
  1934. try {
  1935. if (element.getAttribute('action-type') === 'app_source') a = element;
  1936. else a = element.querySelector('[action-type="app_source"]');
  1937. if (a) {
  1938. var source = a.getAttribute('title') || a.textContent || '未通过审核应用';
  1939. if (source && source !== '微博 weibo.com') return callback({ 'source': source });
  1940. }
  1941. } catch (e) { debug('%o: %o', e, e.stack); }
  1942. callback();
  1943. },
  1944. 'desc': function (dom, val) {
  1945. dom.innerHTML = fillStr('{{{sourceFilterFast}}}', { 'source': escapeXml(val.source) });
  1946. return true;
  1947. },
  1948. 'add': function (val) { return val.source; },
  1949. }
  1950. });
  1951.  
  1952. // 从一条微博中找到所有超链接
  1953. var getFeedHyperlinkList = function (feed) {
  1954. return Array.apply(Array, feed.querySelectorAll('a[title][href^="http://t.cn/"]')).map(function (a) {
  1955. return a.getAttribute('title');
  1956. });
  1957. };
  1958.  
  1959. // 超链接过滤
  1960. var hyperlinkFilterGroup = allInOneFilters({
  1961. 'name': 'hyperlink',
  1962. 'add': function (s) { return s.trim(); },
  1963. 'rule': function hyperlinkMatch(action, feed) {
  1964. var links = this.conf, _links = getFeedHyperlinkList(feed);
  1965. var match = _links.some(function (l) {
  1966. return links.some(function (link) {
  1967. return l.indexOf(link) !== -1;
  1968. });
  1969. });
  1970. if (match) return action; else return null;
  1971. },
  1972. 'fast': {
  1973. 'valid': function (element, callback) {
  1974. if (element.nodeType === Node.TEXT_NODE) return callback();
  1975. try {
  1976. var a;
  1977. if (element.tagName.toLowerCase() === 'a' &&
  1978. element.getAttribute('title') &&
  1979. element.getAttribute('href').indexOf('http://t.cn/') === 0) a = element;
  1980. else a = element.querySelector('a[title][href^="http://t.cn/"]');
  1981. if (a) {
  1982. var x = document.createElement('a'); x.href = a.getAttribute('title');
  1983. if (x.host !== 'weibo.com') return callback({ 'host': x.host });
  1984. }
  1985. } catch (e) { }
  1986. callback();
  1987. },
  1988. 'desc': function (dom, val) {
  1989. dom.innerHTML = fillStr('{{{hyperlinkFilterFast}}}', { 'host': escapeXml(val.host) });
  1990. return true;
  1991. },
  1992. 'add': function (val) { return val.host; },
  1993. },
  1994. });
  1995.  
  1996. var otherFilterGroup = filterGroup('otherFilterGroup');
  1997.  
  1998. otherFilterGroup.add({
  1999. 'type': 'subtitle',
  2000. 'text': '{{otherWhitelistTitle}}'
  2001. });
  2002.  
  2003. // 总是显示自己的微博
  2004. otherFilterGroup.add({
  2005. 'type': 'boolean',
  2006. 'key': 'weibo.other.my_weibo',
  2007. 'text': '{{showMyWeiboDesc}}',
  2008. 'priority': 1e5 - 1e3, // 略低于白名单,但高于其他
  2009. 'rule': function showMyWeiboRule(feed) {
  2010. if (!this.conf) return;
  2011. if (getFeedAuthorId(feed) === config.uid) return 'showme'; else return null;
  2012. },
  2013. });
  2014.  
  2015. // 总是显示自己原创的微博
  2016. otherFilterGroup.add({
  2017. 'type': 'boolean',
  2018. 'key': 'weibo.other.my_original',
  2019. 'text': '{{showMyOriginalDesc}}',
  2020. 'priority': 1e5 - 1e3, // 略低于白名单,但高于其他
  2021. 'rule': function showMyOriginalRule(feed) {
  2022. if (!this.conf) return;
  2023. if (getFeedOriginalId(feed) === config.uid) return 'showme'; else return null;
  2024. },
  2025. });
  2026.  
  2027. // 总是显示自己原创的微博
  2028. otherFilterGroup.add({
  2029. 'type': 'boolean',
  2030. 'key': 'weibo.other.mention_me',
  2031. 'text': '{{showMentionMeDesc}}',
  2032. 'priority': 1e5 - 1e3, // 略低于白名单,但高于其他
  2033. 'rule': function showMentionMeRule(feed) {
  2034. if (!this.conf) return;
  2035. if (getFeedMentionList(feed).indexOf(config.uid) !== -1) return 'showme'; else return null;
  2036. },
  2037. });
  2038.  
  2039. otherFilterGroup.add({
  2040. 'type': 'subtitle',
  2041. 'text': '{{otherBlacklistTitle}}'
  2042. });
  2043.  
  2044. // 推广微博
  2045. otherFilterGroup.add({
  2046. 'type': 'boolean',
  2047. 'key': 'weibo.other.ad_feed',
  2048. 'text': '{{adfeedFilterDesc}}',
  2049. 'priority': 1e5 + 1e3, // 优先于白名单
  2050. 'rule': function adFeedFilterRule(feed) {
  2051. if (!this.conf) return null;
  2052. return feed.getAttribute('feedtype') === 'ad' ? 'hidden' : null;
  2053. },
  2054. });
  2055.  
  2056. // 混入新鲜事流的其他东西
  2057. otherFilterGroup.add({
  2058. 'type': 'boolean',
  2059. 'key': 'weibo.other.fake_weibo',
  2060. 'text': '{{fakeWeiboFilterDesc}}',
  2061. 'rule': function fakeWeiboFilterRule(feed) {
  2062. if (!this.conf) return null;
  2063. if (!feed.getAttribute('mid')) return 'hidden';
  2064. return null;
  2065. },
  2066. });
  2067.  
  2068. // 已删除或没有权限查看的微博的转发
  2069. otherFilterGroup.add({
  2070. 'type': 'boolean',
  2071. 'key': 'weibo.other.deleted_forward',
  2072. 'text': '{{deletedForwardFilterDesc}}',
  2073. 'rule': function deletedForwardFilterRule(feed) {
  2074. if (!this.conf) return null;
  2075. if (feed.getAttribute('isforward') === '1' &&
  2076. !feed.querySelector('.WB_media_expand .WB_info .WB_name')) return 'hidden';
  2077. return null;
  2078. },
  2079. });
  2080.  
  2081. // 投票微博
  2082. otherFilterGroup.add({
  2083. 'type': 'boolean',
  2084. 'key': 'weibo.other.vote_weibo',
  2085. 'text': '{{voteWeiboFilterDesc}}',
  2086. 'rule': function voteWeiboFilterRule(feed) {
  2087. if (!this.conf) return null;
  2088. if (feed.querySelector('.WB_from a[href^="http://vote.weibo.com/"]'))
  2089. return 'hidden';
  2090. return null;
  2091. },
  2092. });
  2093.  
  2094. // 淘宝/天猫商品
  2095. otherFilterGroup.add({
  2096. 'type': 'boolean',
  2097. 'key': 'weibo.other.tb_tm_wb',
  2098. 'text': '{{taobaoTianmaoWeibo}}',
  2099. 'rule': function taobaoTianmaoFilterRule(feed) {
  2100. if (!this.conf) return null;
  2101. if (feed.querySelector('a .icon_fl_tb, a .icon_fl_tmall'))
  2102. return 'hidden';
  2103. return null;
  2104. },
  2105. });
  2106.  
  2107. // 刷屏与版聊
  2108. otherFilterGroup.add({
  2109. 'type': 'subtitle',
  2110. 'text': '{{otherSpammingTitle}}',
  2111. });
  2112.  
  2113. // 添加数量和折叠/隐藏的
  2114. var lotShown = function (defnum, defact) {
  2115. return {
  2116. 'number': {
  2117. 'type': 'number',
  2118. 'default': defnum || 3,
  2119. 'min': 1,
  2120. },
  2121. 'action': {
  2122. 'type': 'select',
  2123. 'default': defact || 'fold',
  2124. 'select': [
  2125. { 'value': 'fold', 'text': '{{foldlistActionDesc}}' },
  2126. { 'value': 'hidden', 'text': '{{blacklistActionDesc}}' },
  2127. ]
  2128. },
  2129. };
  2130. };
  2131.  
  2132. // 相同账号的过多微博
  2133. otherFilterGroup.add({
  2134. 'type': 'boolean',
  2135. 'priority': -1e6, // 低优先级
  2136. 'key': 'weibo.other.same_account',
  2137. 'ref': lotShown(5, 'fold'),
  2138. 'text': '{{sameAccountFilterDesc}}',
  2139. 'rule': function sameAccountRule(feed) {
  2140. if (!this.conf) return null;
  2141. // 如果在分组页面,而且用户设置了分组页面忽略该过滤器,则不工作
  2142. if (sameAccountByGroup.conf && onGroupPage()) return null;
  2143. var author = feed.querySelector('.WB_name[usercard]');
  2144. if (!author) return null;
  2145. var id = author.getAttribute('usercard').split('=')[1];
  2146. var number = document.querySelectorAll('[node-type="feed_list"] ' +
  2147. '.WB_feed_type[yawf-display]:not([yawf-display$="-fold"]):not([yawf-display$="-unfold"]):not([yawf-display$="-hidden"])' +
  2148. '>.WB_feed_datail>.WB_detail>.WB_info>a.WB_name[usercard="id=' + id + '"]').length;
  2149. if (number >= this.ref.number.conf) return 'account-' + this.ref.action.conf; else return null;
  2150. },
  2151. });
  2152.  
  2153.  
  2154. // 相同微博的过多转发
  2155. otherFilterGroup.add({
  2156. 'type': 'boolean',
  2157. 'priority': -1e6, // 低优先级
  2158. 'key': 'weibo.other.same_forward',
  2159. 'ref': lotShown(3, 'fold'),
  2160. 'text': '{{sameForwardFilterDesc}}',
  2161. 'rule': function sameForwardRule(feed) {
  2162. if (!this.conf) return null;
  2163. var omid = feed.getAttribute('omid');
  2164. if (!omid) return null;
  2165. var number = document.querySelectorAll('[node-type="feed_list"] ' +
  2166. '.WB_feed_type[omid="' + omid + '"][yawf-display]:not([yawf-display$="-fold"]):not([yawf-display$="-unfold"]):not([yawf-display$="-hidden"])').length;
  2167. if (number >= this.ref.number.conf) return 'forward-' + this.ref.action.conf; else return null;
  2168. },
  2169. });
  2170.  
  2171. // 分组浏览
  2172. otherFilterGroup.add({
  2173. 'type': 'subtitle',
  2174. 'text': '{{otherGroupTitle}}',
  2175. });
  2176.  
  2177. // 分组浏览不做按帐号隐藏
  2178. var accountByGroup = otherFilterGroup.add({
  2179. 'type': 'boolean',
  2180. 'key': 'weibo.other.group_account',
  2181. 'text': '{{accountByGroup}}',
  2182. });
  2183.  
  2184. // 分组浏览不做刷屏检查
  2185. var sameAccountByGroup = otherFilterGroup.add({
  2186. 'type': 'boolean',
  2187. 'key': 'weibo.other.group_same_account',
  2188. 'text': '{{sameAccountByGroup}}',
  2189. });
  2190.  
  2191. var layoutFilterGroup = filterGroup('layoutFilterGroup');
  2192.  
  2193. layoutFilterGroup.add({
  2194. 'type': 'subtitle',
  2195. 'text': '{{layoutFilterGroupDesc}}',
  2196. });
  2197.  
  2198. // 大部分选择器参考了 眼不见心不烦 脚本
  2199. var layouts = (function () {
  2200. var current = null;
  2201. var subtitle = function (name) {
  2202. layoutFilterGroup.add({
  2203. 'type': 'remark',
  2204. 'text': '{{layoutHide' + name + '}}',
  2205. });
  2206. current = name;
  2207. };
  2208.  
  2209. var item = function (name, cssText, defaultValue) {
  2210. layoutFilterGroup.add({
  2211. 'type': 'boolean',
  2212. 'key': 'weibo.layoutHide' + current + name,
  2213. 'default': defaultValue || false,
  2214. 'text': '{{layoutHide' + current + name + '}}',
  2215. 'ainit': css(cssText),
  2216. });
  2217. };
  2218.  
  2219. subtitle('Icon');
  2220. item('Level', '.icon_bed[node-type="level"], .W_level_ico { display: none !important; }');
  2221. item('Member', '.W_ico16[class*="ico_member"], .ico_member_dis { display: none !important; }');
  2222. item('Approve', '.approve { display: none !important; }');
  2223. item('ApproveCo', '.approve_co { display: none !important; }');
  2224. item('Club', '.ico_club { display: none !important; }');
  2225. item('VGirl', '.ico_vlady { display: none !important; }');
  2226. item('Taobao', '.ico_taobao { display: none !important; }');
  2227. item('Zongyika', '.zongyika2014 { display: none !important; }');
  2228. item('Youji', '.lvxing2014 { display: none !important; }');
  2229.  
  2230. subtitle('Nav');
  2231. item('Main', '.gn_nav>div:nth-child(1) { display: none !important; }');
  2232. item('Hot', '.gn_nav>div:nth-child(2) { display: none !important; }');
  2233. item('App', '.gn_nav>div:nth-child(3) { display: none !important; }');
  2234. item('Game', '.gn_nav>div:nth-child(4) { display: none !important; }');
  2235. item('Member', '.gn_setting[node-type="member"] { display: none !important; }');
  2236.  
  2237. subtitle('Left');
  2238. item('ToMe', '#pl_leftnav_common a[href^="/direct/tome"] { display: none !important; }');
  2239. item('Friends', '#pl_leftnav_group > div[node-type="groupList"] > .level_1_Box, #pl_leftnav_common .level_1_Box > form.left_nav_line { display: none !important; }');
  2240. item('App', '#pl_leftnav_app { display: none !important; }');
  2241.  
  2242. subtitle('Middle');
  2243. item('RecommendedTopic', '#pl_content_publisherTop div[node-type="recommendTopic"] { display: none !important; }');
  2244. item('FeedRecommand', 'a.notes[node-type="feed_list_newBar"][href^="http"]:not([action-type="feed_list_newBar"]) { display: none !important; }');
  2245. item('MemberTip', '[node-type="feed_list_shieldKeyword"] { display: none !important; }');
  2246.  
  2247. subtitle('Right');
  2248. item('Template', '.templete_enter { display: none !important; }');
  2249. item('Info', '.W_person_info { display: none !important; }');
  2250. item('Atten', '#pl_rightmod_myinfo .user_atten { display: none !important; }');
  2251. item('Trial', '#trustPagelet_checkin_lotteryv5 { display: none !important; }');
  2252. item('Interest', '[yawf-id="rightmod_recom_interest"] { display: none !important; }');
  2253. item('HotTopic', '[yawf-id="rightmod_zt_hottopic"] { display: none !important; }');
  2254. item('Member', '#trustPagelet_recom_memberv5 { display: none !important; }');
  2255. item('Weibo', '[yawf-id="rightmod_recom_weibo"] { display: none !important; }');
  2256. item('Location', '[yawf-id="rightmod_recom_location"] { display: none !important; }');
  2257. item('Music', '[yawf-id="rightmod_recom_music"] { display: none !important; }');
  2258. item('Movie', '[yawf-id="rightmod_recom_movie"] { display: none !important; }');
  2259. item('Book', '[yawf-id="rightmod_recom_book"] { display: none !important; }');
  2260. item('Notice', '#pl_rightmod_noticeboard { display: none !important; }');
  2261.  
  2262. subtitle('Weibo');
  2263. item('RecomFeed', '[node-type="feed_list_recommend"] { display: none !important; }');
  2264. item('FeedTip', '[node-type="feed_privateset_tip"] { display: none !important; }');
  2265. item('TopicCard', '.WB_feed_spec[exp-data*="value=1022-topic"] { display: none !important; }');
  2266. item('SonTitle', '.WB_feed_type .WB_feed_together .wft_hd { display: none !important; }');
  2267. item('LocationCard', '.WB_feed_spec[exp-data*="value=1022-place"] { display: none !important; }');
  2268. item('Source', '.WB_time+.S_txt2, .WB_time+.S_txt2+.S_link2 { display: none !important; }');
  2269. item('Report', '.WB_time~.hover { display: none !important; }');
  2270. item('Like', 'a[action-type="feed_list_like"], a[action-type="feed_list_like"]+.S_txt3 { display: none !important; }');
  2271. item('Forward', 'a[action-type="feed_list_forward"], a[action-type="feed_list_forward"]+.S_txt3 { display: none !important; }');
  2272. item('Favourite', 'a[action-type="feed_list_favorite"], a[action-type="feed_list_favorite"]+.S_txt3 { display: none !important; }');
  2273. item('BlockBySource', 'div.layer_menu_list[action-type="feed_list_layer"] a[action-type="feed_list_shield_by_app"] { display: none !important; }');
  2274. item('BlockByKeyword', 'div.layer_menu_list[action-type="feed_list_layer"] a[action-type="feed_list_shield_setkeyword"] { display: none !important; }');
  2275.  
  2276. subtitle('Person');
  2277. item('Cover', funcStr(function () { /*!CSS
  2278. .S_profile_pic { display: none; }
  2279. .profile_top { margin-top: 20px; }
  2280. .profile_top .pf_head { top: 5px; margin-top: 0 !important; }
  2281. .profile_top .pf_head_pic { height: 120px; width: 120px; float: right; }
  2282. .profile_top .pf_head_pic img { height: 120px; }
  2283. .profile_top .pf_head .user_atten { width: 60px; float: left; height: 120px; }
  2284. .profile_top .pf_head .user_atten li, .profile_top .pf_head .user_atten .follower { width: 54px; padding: 0 3px 3px; height: 37px; border-right: none; }
  2285. .profile_top .pf_head .user_atten li strong { margin: 3px 0 0; }
  2286. */ }));
  2287. item('BadgeIcon', '.pf_badge_icon { display: none !important; }');
  2288. item('Stats', '.profile_top .user_atten { display: none !important; } .profile_top .pf_head { margin-top: 51px; } ');
  2289. item('MyData', '.W_main_c [id^="Pl_Official_MyMicroworld__"] { display: none !important; }');
  2290. item('Group', '.W_main_2r [id^="Pl_Core_RightGroupsBtn__"] { display: none !important; }');
  2291. item('SuggestUser', '.W_main_2r [id^="Pl_Core_RightUserList__"] { display: none !important; }');
  2292. item('Relation', '.W_main_2r [id^="Pl_Core_RightUserGrid__"] { display: none !important; }');
  2293. item('Album', '.W_main_2r [id^="Pl_Core_RightPicMulti__"] { display: none !important; }');
  2294. item('HotTopic', '.W_main_2r [id^="Pl_Core_RightTextSingle__"] { display: none !important; }');
  2295. item('HotWeibo', '.W_main_2r [id^="Pl_Core_RightPicText__"] { display: none !important; }');
  2296.  
  2297. subtitle('Other');
  2298. item('Ads', '#plc_main [id^="pl_rightmod_ads"], #Box_right [id^="ads_"], #trustPagelet_zt_hottopicv5 [class*="hot_topicad"], div[ad-data], .WB_feed .popular_buss, [id^="sinaadToolkitBox"] { display: none !important; } #wrapAD, .news_logo { visibility: hidden !important; }');
  2299. item('FeedRecom', '.W_main_2r [id^="Pl_Third_Inline__"] { display: none !important; }');
  2300. item('Footer', '.global_footer { display: none !important; }');
  2301. item('WbIm', '.WBIM_news { display: none !important; }');
  2302. item('Tip', '.layer_tips { display: none !important; }');
  2303.  
  2304. var tagRightbarMods = function () {
  2305. var mods = document.querySelectorAll('#trustPagelet_indexright_recom .WB_right_module:not([yawf-id])');
  2306. if (!mods) return;
  2307. var identifiers = {
  2308. '.right_content.hot_topic': 'rightmod_zt_hottopic',
  2309. '.right_content.person_list': 'rightmod_recom_interest',
  2310. '[change-data*="key=index_weibo"]': 'rightmod_recom_weibo',
  2311. '[change-data*="key=index_LBS"]': 'rightmod_recom_location',
  2312. '[change-data*="key=index_song"]': 'rightmod_recom_music',
  2313. '[change-data*="key=index_mov"]': 'rightmod_recom_movie',
  2314. '[change-data*="key=index_book"]': 'rightmod_recom_book'
  2315. };
  2316. Array.apply(Array, mods).forEach(function (mod) {
  2317. Object.keys(identifiers).forEach(function (qs) {
  2318. if (mod.querySelector(qs)) mod.setAttribute('yawf-id', identifiers[qs]);
  2319. });
  2320. });
  2321. };
  2322.  
  2323. newNode.add(tagRightbarMods);
  2324. tagRightbarMods();
  2325. css.add('.W_miniblog { visibility: visible !important; }');
  2326.  
  2327. }());
  2328.  
  2329. // 改造设置
  2330. var toolFilterGroup = filterGroup('toolFilterGroup');
  2331.  
  2332. // 边栏相关工具
  2333. toolFilterGroup.add({
  2334. 'type': 'subtitle',
  2335. 'text': '{{sideColumnToolsTitle}}',
  2336. });
  2337.  
  2338. // 展开左栏分组
  2339. toolFilterGroup.add({
  2340. 'type': 'boolean',
  2341. 'key': 'weibo.tool.showAllGroup',
  2342. 'text': '{{showAllGroupDesc}}',
  2343. 'ainit': css('#pl_leftnav_group div[node-type="moreList"] { display: block !important } #pl_leftnav_group > div[node-type="groupList"] > .level_2_Box > .levmore { display: none }'),
  2344. });
  2345.  
  2346. // 展开左栏消息
  2347. toolFilterGroup.add({
  2348. 'type': 'boolean',
  2349. 'key': 'weibo.tool.showAllMsgNav',
  2350. 'text': '{{showAllMsgNavDesc}}',
  2351. 'ainit': css('#pl_leftnav_common > .level_1_Box > .lev2_new { display: block !important }'),
  2352. });
  2353.  
  2354. // 合并左右边栏
  2355. var mergeLeftRight = toolFilterGroup.add({
  2356. 'type': 'boolean',
  2357. 'key': 'weibo.tool.mergeColumns',
  2358. 'text': '{{mergeLeftRight}}',
  2359. 'ref': {
  2360. 'side': {
  2361. 'type': 'select',
  2362. 'select': [
  2363. { 'value': 'left', 'text': '{{mergeLeftRightLeft}}' },
  2364. { 'value': 'right', 'text': '{{mergeLeftRightRight}}' },
  2365. ],
  2366. 'default': 'right',
  2367. }
  2368. },
  2369. 'init': function () {
  2370. if (!this.conf) return;
  2371. var main = document.querySelector('.W_main');
  2372. var left = document.querySelector('.W_main_l');
  2373. var attr = 'yawf-left';
  2374. if (!left) return;
  2375. var left0 = cewih('div', '');
  2376. left.parentNode.insertBefore(left0, left);
  2377. left.parentNode.removeChild(left);
  2378. var positionLeft = function () {
  2379. var ref = document.querySelector('#pl_rightmod_myinfo')
  2380. var leftn = document.querySelector('.W_main_l');
  2381. if (leftn) { left = leftn; return; }
  2382. if (ref) ref.parentNode.insertBefore(left, ref.nextSibling);
  2383. else left0.parentNode.insertBefore(left, left0);
  2384. main.setAttribute('yawf-merge-left', ref ? 'merge' : 'none');
  2385. };
  2386. positionLeft();
  2387. newNode.add(function () { positionLeft(); })
  2388. css.add(funcStr(function () { /*!CSS
  2389. .W_main[yawf-merge-left="merge"] .W_main_l { width: 229px; padding: 0; float: none; }
  2390. .W_main[yawf-merge-left="merge"] .WB_left_nav .lev a:hover, .WB_left_nav .lev2 a:hover, .WB_left_nav .lev2 a.lev_curr, .WB_left_nav .lev2 a.lev_curr:hover, .WB_left_nav .lev3 a:hover { background-image: none; }
  2391. .W_main[yawf-merge-left="merge"] { width: 830px; background-position: -300px center; background-size: 200% 100%; }
  2392. body.B_index:not([yawf-weibo-only]) .W_main[yawf-merge-left="merge"]~.W_gotop { margin-left: 415px !important; }
  2393. body.B_index:not([yawf-weibo-only]) #yawf-drop-area { left: calc(50% + 185px); }
  2394. */ }));
  2395. if (this.ref.side.conf === 'left') css.add(funcStr(function () { /*!CSS
  2396. .W_main[yawf-merge-left="merge"] .W_main_r { float: left; }
  2397. .W_main[yawf-merge-left="merge"] .W_main_c { float: right; }
  2398. .W_main[yawf-merge-left="merge"] .templete_enter a { right: auto; left: 0; transform: scaleX(-1); }
  2399. .W_main[yawf-merge-left="merge"] .send_weibo .input .arrow, .send_weibo .input.clicked .arrow { right: auto; left: -11px; transform: scaleX(-1); }
  2400. .W_main[yawf-merge-left="merge"] #Box_center { border-left: 2px solid rgba(128, 128, 128, 0.2); margin-left: -2px; }
  2401. body.B_index:not([yawf-weibo-only]) #yawf-drop-area { left: calc(50% - 415px); }
  2402. */ })); else css.add(funcStr(function () { /*!CSS
  2403. .W_main[yawf-merge-left="merge"] #Box_center { border-right: 2px solid rgba(128, 128, 128, 0.2); margin-right: -2px; }
  2404. */ }));
  2405. },
  2406. });
  2407.  
  2408. // 左边栏浮动
  2409. toolFilterGroup.add({
  2410. 'type': 'boolean',
  2411. 'key': 'weibo.tool.fixedLeft',
  2412. 'text': '{{fixedLeft}}',
  2413. 'default': true,
  2414. 'ref': {
  2415. 'items': {
  2416. 'type': 'select',
  2417. 'select': [
  2418. { 'value': 'default', 'text': '{{fixedLeftDefault}}' },
  2419. { 'value': 'whole', 'text': '{{fixedLeftWhole}}' },
  2420. ],
  2421. 'default': 'default',
  2422. }
  2423. },
  2424. 'init': function () {
  2425. var left = document.querySelector('.W_main_l');
  2426. if (!left) return;
  2427. var type = this.conf ? this.ref.items.conf : 'none';
  2428. var merged = mergeLeftRight.conf;
  2429. // 禁用掉默认的浮动
  2430. css.add('.W_main [node-type="left_fixed"]:not([yawf-fixed]) { height: auto !important; padding-top: 0 !important; position: static !important; top: 40px !important; animation: none; }');
  2431. // 不浮动的如果禁用了默认的浮动,那么就完成了
  2432. if (type === 'none') return;
  2433. // 否则如果合并了左右边栏,而且我要浮动,那么右面就不要动
  2434. if (merged) {
  2435. var removeRightFixed = function () {
  2436. var fixed = document.querySelector('.W_main_r [node-type="right_module_fixed"]');
  2437. if (!fixed) return;
  2438. while (fixed.firstChild) fixed.parentNode.insertBefore(fixed.firstChild, fixed);
  2439. fixed.parentNode.removeChild(fixed);
  2440. };
  2441. removeRightFixed();
  2442. newNode.add(removeRightFixed);
  2443. }
  2444. // 最后自定义的浮动
  2445. css.add('.W_main [yawf-fixed] { animation-duration: 0.5s; animation-iteration-count: 1; animation-name: dropdown; animation-timing-function: ease; position: fixed; top: 65px; overflow: hidden; height: auto; }');
  2446. if (merged) css.add('.W_main [yawf-fixed] { width: 229px; }');
  2447. var container = document.querySelector('.W_main');
  2448. var reference = merged && document.querySelector('.W_main_r') || left;
  2449. var floatitem = type === 'default' && left.querySelector('[node-type="left_fixed"]') || left.querySelector('[node-type="left_all"]');
  2450. var floating = false;
  2451. var updatePosition = function () {
  2452. if (!floating) {
  2453. if (reference.getClientRects()[0].bottom < -65) {
  2454. floating = true;
  2455. floatitem.setAttribute('yawf-fixed', '');
  2456. }
  2457. } else {
  2458. if (reference.getClientRects()[0].bottom > 65 - floatitem.clientHeight) {
  2459. floating = false;
  2460. floatitem.removeAttribute('yawf-fixed');
  2461. call(updatePosition);
  2462. }
  2463. }
  2464. if (floating) {
  2465. var cip = container.getClientRects()[0];
  2466. var fip = floatitem.getClientRects()[0];
  2467. floatitem.style.maxHeight = Math.max(cip.bottom - fip.top - 20, 0) + 'px';
  2468. }
  2469. };
  2470. document.addEventListener('scroll', updatePosition);
  2471. newNode.add(updatePosition);
  2472. updatePosition();
  2473. },
  2474. });
  2475.  
  2476. // 微博相关工具
  2477. toolFilterGroup.add({
  2478. 'type': 'subtitle',
  2479. 'text': '{{weiboToolsTitle}}',
  2480. });
  2481.  
  2482. // 清除发布框中的默认话题 (wcf)
  2483. toolFilterGroup.add({
  2484. 'type': 'boolean',
  2485. 'key': 'weibo.tool.clear_def_topic',
  2486. 'text': '{{clearDefTopicDesc}}',
  2487. 'ainit': function () {
  2488. var clearDefTopic = function () {
  2489. var inputBox = document.querySelector('#pl_content_publisherTop .send_weibo .input textarea');
  2490. if (inputBox && inputBox.hasAttribute('hottopic')) {
  2491. inputBox.removeAttribute('hottopic'); inputBox.removeAttribute('hottopicid');
  2492. inputBox.value = 'DUMMY'; inputBox.focus();
  2493. inputBox.value = ''; inputBox.blur();
  2494. }
  2495. };
  2496. newNode.add(clearDefTopic);
  2497. },
  2498. });
  2499.  
  2500. // 微博作者与正文同行
  2501. toolFilterGroup.add({
  2502. 'type': 'boolean',
  2503. 'key': 'weibo.tool.unwrapText',
  2504. 'text': '{{unwrapTextDesc}}',
  2505. 'ainit': css('.WB_info, .WB_text { display: inline } .WB_info+.WB_text::before { content: ": " } .WB_func { margin-top: 5px } .B_index .WB_feed .W_ico16 { vertical-align: -3px !important }'),
  2506. });
  2507.  
  2508. // 个人主页自动打开微博列表
  2509. toolFilterGroup.add({
  2510. 'type': 'boolean',
  2511. 'key': 'weibo.tool.redirectWeibo',
  2512. 'text': '{{personalRedirectWeibo}}',
  2513. 'ainit': function () {
  2514. var locat = unsafeWindow.$CONFIG.location;
  2515. if (!locat || locat.slice(-5) !== '_home') return;
  2516. if (!document.body.classList.contains('B_profile')) return;
  2517. var from = (location.search.match(/from=([^&]*)/) || {})[1];
  2518. if (locat.indexOf(from) === 0) return;
  2519. var redirect = function () {
  2520. var link = document.querySelector('.PRF_tab_noicon li.pftb_itm a[href*="/weibo?"]'); if (!link) return;
  2521. if (!link) return false;
  2522. newNode.remove(redirect);
  2523. window.stop(); // 虽然不知道为什么,但是加上就正常了……
  2524. location.replace(link.href);
  2525. };
  2526. newNode.add(redirect);
  2527. redirect();
  2528. },
  2529. });
  2530.  
  2531. // 查看大图旁添加查看原图链接
  2532. toolFilterGroup.add({
  2533. 'type': 'boolean',
  2534. 'default': true,
  2535. 'key': 'weibo.tool.viewOriginal',
  2536. 'text': '{{viewOriginalDesc}}',
  2537. 'ainit': function () {
  2538. var addOriLink = function () {
  2539. var a = document.querySelector('a.show_big[action-data]:not([yawf-viewori])');
  2540. if (!a) return; a.setAttribute('yawf-viewori', 'yawf-viewori');
  2541. var arg = a.getAttribute('action-data').match(/pid=(\w+)&mid=(\d+)&uid=(\d+)/);
  2542. if (!arg) return;
  2543. var vol = cewih('div', fillStr(html.viewOriginalLink)), l = vol.firstChild;
  2544. l.href = fillStr(url.view_ori, { 'uid': arg[3], 'mid': arg[2], 'pid': arg[1] });
  2545. while (vol.firstChild) a.parentNode.insertBefore(vol.firstChild, a);
  2546. };
  2547. newNode.add(addOriLink);
  2548. },
  2549. });
  2550.  
  2551. // 展开 t.cn 短网址
  2552. toolFilterGroup.add({
  2553. 'type': 'boolean',
  2554. 'key': 'weibo.tool.expandTCn',
  2555. 'text': '{{expandShortenedLink}}',
  2556. 'ainit': function () {
  2557. var expandLink = function () {
  2558. var links = Array.apply(Array, document.querySelectorAll('.WB_text a[mt="url"][title^="http"]:not([yawf-expand])'));
  2559. links.forEach(function (link) {
  2560. link.setAttribute('yawf-expand', 'expand');
  2561. if (link.textContent.indexOf('http://t.cn/') !== 0) return;
  2562. link.textContent = link.title;
  2563. });
  2564. };
  2565. newNode.add(expandLink);
  2566. expandLink();
  2567. },
  2568. });
  2569.  
  2570. // 脚本工具
  2571. toolFilterGroup.add({
  2572. 'type': 'subtitle',
  2573. 'text': '{{scriptToolsTitle}}',
  2574. });
  2575.  
  2576. // 快速创建过滤器
  2577. toolFilterGroup.add({
  2578. 'type': 'boolean',
  2579. 'key': 'weibo.tool.use_fast_creator',
  2580. 'default': true,
  2581. 'text': '{{useFastCreator}}',
  2582. 'ainit': function () {
  2583. dropdown.init();
  2584. },
  2585. });
  2586.  
  2587.  
  2588. // 屏蔽隐藏微博
  2589. toolFilterGroup.add({
  2590. 'type': 'boolean',
  2591. 'key': 'weibo.tool.block_hidden',
  2592. 'text': '{{blockHiddenWeiboDesc}}',
  2593. 'ainit': function () {
  2594. eachWeibo.after(function (feed) {
  2595. [feed].concat(Array.apply(Array, feed.querySelectorAll('.WB_feed_type'))).forEach(function (feed) {
  2596. var display = feed.getAttribute('yawf-display');
  2597. if (display !== 'display-hidden') return;
  2598. if (!feed.getAttribute('mid')) return;
  2599. blockWeibo(feed.getAttribute('mid'));
  2600. feed.setAttribute('yawf-block', 'block');
  2601. });
  2602. });
  2603. }
  2604. });
  2605.  
  2606. // 样式相关工具
  2607. toolFilterGroup.add({
  2608. 'type': 'subtitle',
  2609. 'text': '{{styleToolsTitle}}',
  2610. });
  2611.  
  2612. // 一个带有颜色/透明度的选框项
  2613. var coloredConfigItem = function (details) {
  2614.  
  2615. // 将颜色和透明度转换为一个表示颜色的字符串
  2616. var colorStr = function (color, transparency) {
  2617. return 'rgba(' + color.slice(1)
  2618. .split(/(..)/).filter(function (x) { return x; })
  2619. .map(function (x) { return parseInt(x, 16); }).join(',') +
  2620. ',' + (100 - transparency) / 100 + ')';
  2621. };
  2622.  
  2623. var color = {
  2624. 'type': 'color',
  2625. 'default': details.color || '#000000',
  2626. };
  2627. var transparency = {
  2628. 'type': 'range',
  2629. 'default': details.transparency || 0,
  2630. 'min': 0,
  2631. 'max': 100,
  2632. };
  2633. return {
  2634. 'color': color,
  2635. 'transparency': transparency,
  2636. 'rgba': {
  2637. 'toString': function () {
  2638. return colorStr(color.conf, transparency.conf);
  2639. },
  2640. }
  2641. };
  2642. };
  2643.  
  2644. // 高亮显示白名单微博
  2645. toolFilterGroup.add({
  2646. 'type': 'boolean',
  2647. 'key': 'weibo.tool.whitelist_highlight',
  2648. 'ref': coloredConfigItem({ 'color': '#fef3da' }),
  2649. 'text': '{{whitelistHighlightDesc}}',
  2650. 'ainit': function () {
  2651. css.add(fillStr(funcStr(function () { /*
  2652. .WB_media_expand .WB_arrow { display: none !important; }
  2653. [node-type="feed_list"] .WB_feed_type[yawf-display$="-show"] { background-color: {{color}} !important; box-shadow: -20px 0 0 {{color}}, 20px 0 0 {{color}}; }
  2654. [node-type="feed_list"] .WB_feed_together .WB_feed_type[yawf-display$="-show"] { background-color: {{color}} !important; box-shadow: -10px 0 0 {{color}}, 10px 0 0 {{color}}; }
  2655. */ }), { 'color': '' + this.ref.rgba }));
  2656. },
  2657. });
  2658.  
  2659. // 首页背景
  2660. toolFilterGroup.add({
  2661. 'type': 'boolean',
  2662. 'key': 'weibo.tool.my_background_color',
  2663. 'ref': coloredConfigItem({
  2664. 'color': '#ffffff',
  2665. 'transparency': 30,
  2666. }),
  2667. 'text': '{{mainBackgroundColorOverride}}',
  2668. 'ainit': function () {
  2669. css.add(fillStr(funcStr(function () { /*
  2670. body:not(.S_profile) .W_main { background-image: none !important; background-color: {{color}} !important }
  2671. body:not(.S_profile) .S_bg4, body:not(.S_profile) .W_main_a, body:not(.S_profile) .W_main_bg { background: transparent !important; }
  2672. */ }), { 'color': '' + this.ref.rgba }));
  2673. },
  2674. });
  2675.  
  2676. // 个人主页背景
  2677. toolFilterGroup.add({
  2678. 'type': 'boolean',
  2679. 'key': 'weibo.tool.other_background_color',
  2680. 'ref': coloredConfigItem({
  2681. 'color': '#ffffff',
  2682. 'transparency': 30,
  2683. }),
  2684. 'text': '{{profileBackgroundColorOverride}}',
  2685. 'ainit': function () {
  2686. css.add(fillStr(funcStr(function () { /*
  2687. .S_profile .W_profile_bg, .S_profile .S_bg5 { background-color: {{color}} !important; }
  2688. .S_profile .S_bg4:not(.W_profile_bg) { background: none transparent !important }
  2689. */ }), { 'color': '' + this.ref.rgba }));
  2690. },
  2691. });
  2692.  
  2693. // 阅读模式
  2694. toolFilterGroup.add({
  2695. 'type': 'boolean',
  2696. 'text': '{{weiboOnly}}',
  2697. 'key': 'weibo.tool.weibo_only',
  2698. 'ref': extend({
  2699. // 宽度
  2700. 'width': {
  2701. 'type': 'range',
  2702. 'min': 480,
  2703. 'max': 980,
  2704. 'default': 600,
  2705. },
  2706. // 快捷键
  2707. 'key': {
  2708. 'type': 'key',
  2709. 'default': 119 // F8
  2710. },
  2711. // 是否显示快捷链接
  2712. 'switch': {
  2713. 'type': 'boolean',
  2714. 'default': false,
  2715. },
  2716. 'usebgc': {
  2717. 'type': 'boolean',
  2718. },
  2719. }, coloredConfigItem({
  2720. // 颜色
  2721. 'color': '#ffffff',
  2722. // 透明度
  2723. 'transparency': 20,
  2724. }), {
  2725. 'enabled': {
  2726. 'type': 'boolean',
  2727. 'default': false,
  2728. 'internal': true,
  2729. },
  2730. }),
  2731. 'ainit': function () {
  2732. if (!document.body.classList.contains('B_index') &&
  2733. !document.body.classList.contains('B_profile')) return;
  2734. var that = this;
  2735. var key = that.ref.key, attr = 'yawf-weibo-only';
  2736. // 切换阅读模式开关
  2737. var switchMode = function (enable) {
  2738. var enabled = document.body.hasAttribute(attr);
  2739. if (enable == null) enable = !enabled;
  2740. else if (enable === enabled) return;
  2741. if (enable) document.body.setAttribute(attr, attr);
  2742. else document.body.removeAttribute(attr);
  2743. that.ref.enabled.putconf(enable);
  2744. };
  2745. // 检查快捷键按键
  2746. keys.reg(key.conf, function () {
  2747. // 只有有切换按钮的时候才生效
  2748. if (document.querySelector('.group_read .right_bar[yawf-weibo-only-added]'))
  2749. switchMode();
  2750. });
  2751. // 显示切换按钮
  2752. if (that.ref['switch'].conf) {
  2753. var showSwitch = function () {
  2754. var rightBar = document.querySelector('.group_read .right_bar:not([yawf-weibo-only-added])');
  2755. if (!rightBar) return; rightBar.setAttribute('yawf-weibo-only-added', 'added');
  2756. var weiboOnly = cewih('div', fillStr(html.weiboOnlyButton, {
  2757. 'text': text.weiboOnlyButton,
  2758. 'shortcut': key.conf === 0 ? '' : ' (' + keys.name(key.conf) + ')',
  2759. })).firstChild;
  2760. weiboOnly.addEventListener('click', switchMode.bind(that, null));
  2761. rightBar.insertBefore(weiboOnly, rightBar.querySelector('.right_item~.right_item'));
  2762. newNode.remove(showSwitch);
  2763. };
  2764. newNode.add(showSwitch);
  2765. }
  2766. // 注册样式
  2767. css.add(fillStr(funcStr(function () { /*!CSS
  2768. body.B_index[{{attr}}] .W_main_l,
  2769. body.B_index[{{attr}}] .W_main_r,
  2770. body.B_index[{{attr}}] #Box_center>div:not(#pl_content_homeFeed),
  2771. body.B_index[{{attr}}] .global_footer { display: none; }
  2772. body.B_profile[{{attr}}] #Pl_Official_Header__1,
  2773. body.B_profile[{{attr}}] #Pl_Core_Header__1,
  2774. body.B_profile[{{attr}}] #Pl_Core_Nav__2,
  2775. body.B_profile[{{attr}}] .W_main_2r,
  2776. body.B_profile[{{attr}}] .global_footer { display: none; }
  2777. body.B_index[{{attr}}] .WB_global_nav,
  2778. body.B_profile[{{attr}}] .WB_global_nav { position: absolute !important; }
  2779. body.B_index[{{attr}}] .W_miniblog,
  2780. body.B_profile[{{attr}}] .W_miniblog { padding-top: 60px; }
  2781. body.B_index[{{attr}}] .WB_feed .WB_screen,
  2782. body.B_profile[{{attr}}] .WB_feed .WB_screen { margin-left: calc({{width}} - 48px); }
  2783. body.B_index[{{attr}}] .W_main,
  2784. body.B_profile[{{attr}}] .W_main { width: {{width}} !important; background-position: 40% center; background-size: 165% 100%; }
  2785. body.B_index[{{attr}}] #Box_center,
  2786. body.B_index[{{attr}}] .WB_feed .repeat .input textarea,
  2787. body.B_profile[{{attr}}] .WB_feed .repeat .input textarea { width: 100%; }
  2788. body.B_index[{{attr}}] .WB_feed .type_text,
  2789. body.B_profile[{{attr}}] .WB_feed .type_text { margin-left: calc({{width}} - 165px); }
  2790. body.B_index[{{attr}}] .W_gotop,
  2791. body.B_profile[{{attr}}] .W_gotop { margin-left: calc({{width}} / 2) !important; }
  2792. body.B_index[{{attr}}] .WB_feed .between_line,
  2793. body.B_profile[{{attr}}] .WB_feed .between_line { padding: 0 calc({{width}} / 2 - 132px) !important; }
  2794. body.B_index[{{attr}}] .WB_media_expand .WB_arrow,
  2795. body.B_profile[{{attr}}] .WB_media_expand .WB_arrow { display: none !important; }
  2796. body.B_index[{{attr}}] #yawf-drop-area,
  2797. body.B_profile[{{attr}}] #yawf-drop-area { left: calc(50% + {{width}} / 2 - 230px); top: 0; }
  2798. body.B_index[{{attr}}] .W_main_a { width: {{width}}; }
  2799. body.B_profile[{{attr}}] .W_main_c { padding-top: 9px; width: {{width}}; }
  2800. .input_search { float: left; }
  2801. */ }), {
  2802. 'width': that.ref.width.conf + 'px',
  2803. 'attr': attr,
  2804. }));
  2805. if (that.ref.usebgc.conf) css.add('body.B_index[' + attr + '] .W_main, body.B_profile[' + attr + '] .W_main { background: ' + that.ref.rgba + ' !important; }');
  2806. var updateModeByConf = function () {
  2807. switchMode.call(that, that.ref.enabled.getconf());
  2808. };
  2809. updateModeByConf();
  2810. window.addEventListener('focus', updateModeByConf);
  2811. }
  2812. });
  2813.  
  2814. // 自定义样式
  2815. toolFilterGroup.add({
  2816. 'type': 'string',
  2817. 'text': '{{userstyleTitle}}',
  2818. 'key': 'weibo.tool.userstyle',
  2819. 'init': function () {
  2820. var conf = this.conf; GM_addStyle(conf);
  2821. var set = this.putconf.bind(this);
  2822. // 在 GM 中注册菜单项以支持对自定义 CSS 的修改
  2823. // 此处并非常规设置方式,仅应在因用户加入的CSS导致无法正常显示脚本设置界面时使用。
  2824. // 所以此处设置时不应依赖网页界面实现。
  2825. var putconf = function (css) {
  2826. conf = css;
  2827. setTimeout(function () { set(css); config.write(); location.reload(); }, 0);
  2828. };
  2829. GM_registerMenuCommand(fillStr('{{userstyleEditDesc}}'), function () {
  2830. var newcss = prompt(fillStr('{{userstyleEditDetails}}'), conf);
  2831. if (newcss !== null) putconf(newcss);
  2832. }, "S");
  2833. },
  2834. });
  2835.  
  2836. // 脚本设置
  2837. var scriptFilterGroup = filterGroup('scriptFilterGroup');
  2838.  
  2839. // 导入导出
  2840. scriptFilterGroup.add({
  2841. 'type': 'subtitle',
  2842. 'text': '{{configImportAndExport}}',
  2843. });
  2844.  
  2845. scriptFilterGroup.add({
  2846. 'show': function () {
  2847. var dom = cewih('div', html.configImportExport).firstChild;
  2848. var bii = dom.querySelector('input[type="file"]');
  2849. var be = dom.querySelector('[node-type="export"]');
  2850. var br = dom.querySelector('[node-type="reset"]');
  2851. // 导出按钮
  2852. var updateExportButton = function () {
  2853. be.href = 'data:application/octet-stream;base64,' +
  2854. btoa(unescape(encodeURIComponent(config.export())));
  2855. be.setAttribute('download', 'yawf-config.yawf');
  2856. };
  2857. // 导入按钮
  2858. var doImport = function (file) {
  2859. var reader = new FileReader();
  2860. // 导入成功
  2861. var success = function () {
  2862. Alert('yawf-config-import-success', {
  2863. 'title': fillStr('{{configImportSuccessTitle}}'),
  2864. 'text': fillStr('{{configImportSuccess}}'),
  2865. 'icon': 'succ'
  2866. });
  2867. };
  2868. // 导入失败
  2869. var error = function () {
  2870. Alert('yawf-config-import-fail', {
  2871. 'title': fillStr('{{configImportFailTitle}}'),
  2872. 'text': fillStr('{{configImportFail}}'),
  2873. 'icon': 'error'
  2874. });
  2875. };
  2876. // 读文件
  2877. if (file.size > (1 << 24)) error();
  2878. else reader.addEventListener('load', function () {
  2879. if (config.import(reader.result)) {
  2880. updateExportButton();
  2881. success();
  2882. } else error();
  2883. });
  2884. reader.readAsText(file);
  2885. bii.value = '';
  2886. };
  2887. bii.addEventListener('change', function () {
  2888. var file = bii.files[0];
  2889. Confirm('yawf-config-import-warning', {
  2890. 'title': fillStr('{{configImportWarningTitle}}'),
  2891. 'text': fillStr('{{configImportWarning}}'),
  2892. 'onOk': function () { doImport(file); },
  2893. });
  2894. });
  2895. updateExportButton();
  2896. // 重置按钮
  2897. var doReset = function () {
  2898. config.clear();
  2899. updateExportButton();
  2900. };
  2901. br.addEventListener('click', function () {
  2902. Confirm('yawf-config-reset-warning', {
  2903. 'title': fillStr('{{configResetWarningTitle}}'),
  2904. 'text': fillStr('{{configResetWarning}}'),
  2905. 'onOk': doReset,
  2906. });
  2907. });
  2908. return dom;
  2909. },
  2910. });
  2911.  
  2912. // 调试
  2913. scriptFilterGroup.add({
  2914. 'type': 'subtitle',
  2915. 'text': '{{scriptDebugTitle}}',
  2916. });
  2917.  
  2918. scriptFilterGroup.add({
  2919. 'type': 'boolean',
  2920. 'text': '{{scriptDebug}}',
  2921. 'getconf': function () { return !!GM_getValue('debug', false); },
  2922. 'putconf': function (value) { GM_setValue('debug', !!value); return !!value; },
  2923. });
  2924.  
  2925. // 关于
  2926. scriptFilterGroup.add({
  2927. 'type': 'subtitle',
  2928. 'text': '{{scriptAboutTitle}}',
  2929. });
  2930.  
  2931. scriptFilterGroup.add({
  2932. 'type': 'text', 'text': '',
  2933. 'shown': function (dom) {
  2934. dom.innerHTML = fillStr(text.scriptAbout, {
  2935. 'version': ((GM_info || {}).script || {}).version || '?'
  2936. });
  2937. },
  2938. });
  2939.  
  2940. scriptFilterGroup.add({
  2941. 'init': function () {
  2942. var isEn = i18n.lang === 'en';
  2943. css.add(fillStr(funcStr(function () { /*!CSS
  2944. .profile_tab .pftb_lk { padding-left: {{headerWidth}}; padding-right: {{headerWidth}}; }
  2945. .profile_tab .current.pftb_lk { padding-left: {{headerWidth2}}; padding-right: {{headerWidth2}}; }
  2946. .layoutFilterGroupLayer .yawf-configBoolean { width: {{layoutOptionWidth}}; }
  2947. */ }), {
  2948. 'headerWidth': isEn ? '12px' : '15px',
  2949. 'headerWidth2': isEn ? '9px' : '12px',
  2950. 'layoutOptionWidth': isEn ? '320px' : '160px',
  2951. }));
  2952. },
  2953. });
  2954.  
  2955. // 检查是否要在本页上运行
  2956. var validPage = function () {
  2957. if (self !== top) return false;
  2958. if (!unsafeWindow.$CONFIG) return false;
  2959. if (!unsafeWindow.$CONFIG.uid) return false;
  2960. if (!unsafeWindow.$CONFIG.lang) return false;
  2961. return true;
  2962. };
  2963.  
  2964. // 完成加载时
  2965. var dcl = function () {
  2966. if (!validPage()) return;
  2967. // 初始化用户语言
  2968. i18n(unsafeWindow.$CONFIG.lang);
  2969. // 加载用户配置
  2970. config = config(unsafeWindow.$CONFIG.uid);
  2971. // 初始化文本和网页数据(基于用户选择的语言)
  2972. Object.keys(text).map(function (key) { i18n(text[key]); text[key] = text[key].local; });
  2973. Object.keys(html).map(function (key) { html[key] = fillStr(html[key]); });
  2974. // 初始化所有过滤器
  2975. filters.init();
  2976. // 初始化折叠微博后的显示
  2977. fixFoldWeibo.init();
  2978. // 注册样式
  2979. css.init();
  2980. // 初始化界面
  2981. showIcon();
  2982. // 开始过滤
  2983. newNode.active();
  2984. };
  2985. if (document.body) call(dcl);
  2986. else document.addEventListener('DOMContentLoaded', dcl);
  2987.  
  2988. GM_addStyle(fillStr((funcStr(function () { /*!CSS
  2989. // 在顶部添加按钮
  2990. .gn_setting[node-type="member"]:last-child { margin-right: 44px; }
  2991. .WB_global_nav .gn_setting .gn_tab.gn_filter .ico { background-image: url("{{filter-img}}"); !important; background-position: 0 0 !important; }
  2992. .WB_global_nav .gn_search { width: 210px !important; left: 440px !important; position: absolute !important; }
  2993. .WB_global_nav .gn_search .gn_input { width: 168px !important; }
  2994. // 设置框相关样式
  2995. .yawf-Layer.yawf-drag { opacity: 0.67; -moz-user-select: none; user-select: none; }
  2996. #yawf-config [node-type="inner"] { padding: 20px; }
  2997. .yawf-config-body { margin: -20px; max-height: 360px; overflow-y: auto; padding: 20px; width: 760px; }
  2998. #yawf-config .profile_tab { font-size: 12px; margin: -20px -20px 20px; width: 800px; }
  2999. .yawf-config-layer { padding-bottom: 20px; }
  3000. .yawf-groupSubtitle, .yawf-groupRemark { margin: 5px 10px; padding: 10px 0 0 0; }
  3001. .yawf-groupSubtitle { font-weight: bold; }
  3002. .yawf-configInput { display: inline; }
  3003. .yawf-configStringInput { display: block; }
  3004. .yawf-configItem, .yawf-groupText { margin: 0 20px; padding: 0 0; }
  3005. .yawf-configItem { line-height: 30px; }
  3006. .yawf-groupText { line-height: 1em; }
  3007. .yawf-groupText p { margin: 2px 0 0; }
  3008. .yawf-configKeyInput button { padding: 0 1em; }
  3009. .yawf-configItem label+label { margin-left: 0.5em; }
  3010. .yawf-configItem br+label { margin-left: 4em; }
  3011. .yawf-whitelistFilterTitle::before, .yawf-blacklistFilterTitle::before, .yawf-foldlistFilterTitle::before { content: " "; display: inline-block; width: 0.8em; height: 0.8em; border-radius: 1em; margin-right: 0.5em; border: 1px solid white; vertical-align: middle; }
  3012. .yawf-whitelistFilterTitle::before { background: #37c837; box-shadow: 0 0 2px #37c837; }
  3013. .yawf-blacklistFilterTitle::before { background: #c83737; box-shadow: 0 0 2px #c83737; }
  3014. .yawf-foldlistFilterTitle::before { background: #c8c837; box-shadow: 0 0 2px #c8c837; }
  3015. .yawf-configString span { line-height: 16px; width:calc(100% - 56px); margin: 1px 1px -21px; padding: 2px 10px; display: block; position: relative; }
  3016. .yawf-configString textarea.W_input { width: calc(100% - 20px); padding-top: 20px; min-height: 80px; resize: vertical; background: linear-gradient(to bottom, -moz-Dialog 0px, -moz-Dialog 20px, transparent 21px, transparent 100%); }
  3017. .yawf-configStringsInput, .yawf-configUsersInput { margin: 5px; }
  3018. .yawf-configStringsItems, .yawf-configUsersItems { padding: 5px 10px; line-height: 1em; }
  3019. .yawf-configStringsItem, .yawf-configUsersItem { display: inline-block; margin: 2px; }
  3020. .yawf-configStringsItem a.icon_close, .yawf-configUsersItem a.icon_close { margin-left: 3px; vertical-align: -2px; }
  3021. .yawf-configUsersItem .shield_object_card { display: inline-block; }
  3022. .yawf-configUsersItem .shield_object_card .card_bg { border: 1px solid #e6e6e6; border-radius: 2px; box-shadow: 0 1px 1px rgba(0, 0, 0, 0.02); padding: 1px 5px 1px 1px; }
  3023. .yawf-configUsersItem .shield_object_card .card_pic { float: left; width: 50px; }
  3024. .yawf-configUsersItem .shield_object_card .card_pic .pic_box { display: block; }
  3025. .yawf-configUsersItem .shield_object_card .card_content { margin-left: 60px; }
  3026. .yawf-configUsersItem .shield_object_card .object_info { height: 22px; margin-top: 2px; }
  3027. .yawf-configUsersItem .shield_object_card .object_name { line-height: 22px; overflow: hidden; }
  3028. .yawf-configUsersItem .shield_object_card .other_info { line-height: 24px; }
  3029. .yawf-configImportExport [node-type] { margin-right: 20px; }
  3030. .yawf-configAdd { appearance: none; }
  3031. #yawf-config .btn { border-top: 1px solid #ccc; margin: 15px 0 0; padding: 10px 0 0; }
  3032. #yawf-config .btn .W_btn_b_disable:hover { border-color: #d9d9d9; }
  3033. #yawf-config .btn .W_btn_b_disable:hover span { border-color: #ffffff; }
  3034. .layoutFilterGroupLayer .yawf-configBoolean { display: inline-block; margin-right: 0; }
  3035. .yawf-userstyles-tip { float: right; }
  3036. // 隐藏微博
  3037. [yawf-display$="-hidden"] { display: none !important; }
  3038. [node-type="feed_list"] .WB_feed_type:not([yawf-display]), [node-type="feed_list"] .WB_feed_type .WB_feed_type:not([yawf-display]) { visibility: hidden !important; }
  3039. // 折叠微博
  3040. [node-type="feed_list"] .WB_feed_type[yawf-display$="-fold"]::before { display: block; width: 100%; height: 24px; line-height: 24px; padding: 0 2em 20px; border-bottom: #e6e6e6 1px solid; }
  3041. [node-type="feed_list"] .WB_feed_type[yawf-display$="-fold"] { height: 45px; overflow: hidden; cursor: pointer; }
  3042. [node-type="feed_list"] .WB_feed_type[yawf-display$="-fold"] .WB_screen { margin-top: -40px !important; }
  3043. [node-type="feed_list"] .WB_feed_type[yawf-display$="-fold"] .WB_feed_datail,
  3044. [node-type="feed_list"] .WB_feed_type[yawf-display$="-fold"] .type_spe_pos { display: none !important; }
  3045. // 子微博
  3046. [node-type="feed_list"] .WB_feed_type[yawf-display$="-hidden"]+.WB_feed_type[yawf-display$="-son"],
  3047. [node-type="feed_list"] .WB_feed_type[yawf-display$="-fold"]+.WB_feed_type[yawf-display$="-son"] { display: none !important; }
  3048. [node-type="feed_list"] .WB_feed_type:not([yawf-display$="-son"]) .WB_feed_together { display: none !important; }
  3049. [node-type="feed_list"] .WB_feed_type[yawf-withson="son"] .WB_feed_datail,
  3050. [node-type="feed_list"] .WB_feed_type[yawf-withson="son"][yawf-display$="-fold"]::before { border: 0 none !important; }
  3051. [node-type="feed_list"] .WB_feed_type[yawf-display$="-son"] { padding-top: 0 !important; }
  3052. [node-type="feed_list"] .WB_feed_type[yawf-display$="-son"]>.WB_screen,
  3053. [node-type="feed_list"] .WB_feed_type[yawf-display$="-son"]>.WB_feed_datail>.WB_face,
  3054. [node-type="feed_list"] .WB_feed_type[yawf-display$="-son"]>.WB_feed_datail>.WB_detail>*:not(.WB_feed_together) { display: none !important; }
  3055. [node-type="feed_list"] .WB_feed_type[yawf-display$="-son"]>.WB_feed_datail>.WB_detail { margin-top: -20px; margin-bottom: -10px; }
  3056. // 其他
  3057. .WB_feed_together .wft_users { display: none; }
  3058. .WB_feed_together[yawf-sonfold="display"] [node-type="feed_list_wrapForward"] { display: block !important; }
  3059. .WB_feed_together[yawf-sonfold="display"] [action-type="feed_list_seeAll"],
  3060. .WB_feed_together[yawf-sonfold="display"] [action-type="feed_list_foldForward"] { display: none !important; }
  3061. .W_miniblog { visibility: hidden; }
  3062. .yawf-range-container { background-color: #f0f0f0; background-color: -moz-dialog; position: relative; display: inline-block; margin-left: -66px; width: 81px; margin-right: -15px; -webkit-transform: rotate(270deg); transform: rotate(270deg); top: calc(-1em - 36px); box-shadow: 0px 12px #f0f0f0, 0px -12px #f0f0f0; box-shadow: 0px 12px -moz-dialog, 0px -12px -moz-dialog; }
  3063. input[type="number"]:not(:focus) ~ .yawf-range-container:not(:hover) > input[type="range"]:not(:focus) { display: none; }
  3064. // 拖拽
  3065. #yawf-drop-area { background: rgba(251, 251, 216, 0.8); display: none; height: 230px; left: calc(50% + 260px); position: fixed; top: 40px; width: 230px; z-index: 9999; }
  3066. .yawf-drop-area-desc { height: 170px; width: 170px; margin: 16px 16px -206px 16px; padding: 10px; -moz-user-select: none; user-select: none; border: 4px dashed #ddd; border-radius: 20px; }
  3067. .yawf-drop-area-title { font-size: 150%; font-weight: bold; }
  3068. .yawf-drop-area-text { padding: 10px; }
  3069. #yawf-drop-area-content { height: 230px; width: 230px; position: relative; z-index: 10002; opacity: 0; }
  3070. #yawf-fast-filter-chose, #yawf-fast-filter-list { padding: 20px 40px; }
  3071. #yawf-fast-filter-text { font-weight: bold; }
  3072. */ }) + '\n').replace(/\/\/.*\n/g, '\n'), {
  3073. 'filter-img': images.filter,
  3074. }));