Yet Another Weibo Filter

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

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

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