weicano

Weibo.cn cleaner

当前为 2017-08-09 提交的版本,查看 最新版本

  1. /******/ (function(modules) { // webpackBootstrap
  2. /******/ // The module cache
  3. /******/ var installedModules = {};
  4. /******/
  5. /******/ // The require function
  6. /******/ function __webpack_require__(moduleId) {
  7. /******/
  8. /******/ // Check if module is in cache
  9. /******/ if(installedModules[moduleId]) {
  10. /******/ return installedModules[moduleId].exports;
  11. /******/ }
  12. /******/ // Create a new module (and put it into the cache)
  13. /******/ var module = installedModules[moduleId] = {
  14. /******/ i: moduleId,
  15. /******/ l: false,
  16. /******/ exports: {}
  17. /******/ };
  18. /******/
  19. /******/ // Execute the module function
  20. /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
  21. /******/
  22. /******/ // Flag the module as loaded
  23. /******/ module.l = true;
  24. /******/
  25. /******/ // Return the exports of the module
  26. /******/ return module.exports;
  27. /******/ }
  28. /******/
  29. /******/
  30. /******/ // expose the modules object (__webpack_modules__)
  31. /******/ __webpack_require__.m = modules;
  32. /******/
  33. /******/ // expose the module cache
  34. /******/ __webpack_require__.c = installedModules;
  35. /******/
  36. /******/ // define getter function for harmony exports
  37. /******/ __webpack_require__.d = function(exports, name, getter) {
  38. /******/ if(!__webpack_require__.o(exports, name)) {
  39. /******/ Object.defineProperty(exports, name, {
  40. /******/ configurable: false,
  41. /******/ enumerable: true,
  42. /******/ get: getter
  43. /******/ });
  44. /******/ }
  45. /******/ };
  46. /******/
  47. /******/ // getDefaultExport function for compatibility with non-harmony modules
  48. /******/ __webpack_require__.n = function(module) {
  49. /******/ var getter = module && module.__esModule ?
  50. /******/ function getDefault() { return module['default']; } :
  51. /******/ function getModuleExports() { return module; };
  52. /******/ __webpack_require__.d(getter, 'a', getter);
  53. /******/ return getter;
  54. /******/ };
  55. /******/
  56. /******/ // Object.prototype.hasOwnProperty.call
  57. /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
  58. /******/
  59. /******/ // __webpack_public_path__
  60. /******/ __webpack_require__.p = "";
  61. /******/
  62. /******/ // Load entry module and return exports
  63. /******/ return __webpack_require__(__webpack_require__.s = 0);
  64. /******/ })
  65. /************************************************************************/
  66. /******/ ([
  67. /* 0 */
  68. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  69.  
  70. "use strict";
  71. Object.defineProperty(__webpack_exports__, "__esModule", { value: true });
  72. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__gm__ = __webpack_require__(1);
  73. // ==UserScript==
  74. // @name weicano
  75. // @namespace javran.github.io
  76. // @description Weibo.cn cleaner
  77. // @include https://weibo.cn/*
  78. // @version 1.2
  79. // @grant GM_getValue
  80. // @grant GM_setValue
  81. // @require http://code.jquery.com/jquery-3.2.1.min.js
  82. // @require https://code.jquery.com/ui/1.12.1/jquery-ui.min.js
  83. // @require https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.17.4/lodash.min.js
  84. // ==/UserScript==
  85.  
  86.  
  87.  
  88. const applyFilters = () => {
  89. const activeKeywords = _.flatMap(
  90. Object(__WEBPACK_IMPORTED_MODULE_0__gm__["a" /* getKeywords */])(),
  91. ([kw,active]) => active ? [kw] : []
  92. )
  93. const shouldBlock = node => {
  94. const jqNode = $(node)
  95. return activeKeywords.some(keyword =>
  96. jqNode.find(`div:contains('${keyword}')`).length
  97. )
  98. }
  99.  
  100. $("html body div[id*='M_'].c").each((_ind,x) => {
  101. const jq = $(x)
  102. if (shouldBlock(x)) {
  103. jq.hide().next('.s').hide()
  104. } else {
  105. jq.show().next('.s').show()
  106. }
  107. })
  108. }
  109.  
  110. const mkDialogContent = () => {
  111. const jqDlg = $('#weicano-dialog')
  112. const dlg = jqDlg.dialog(
  113. {
  114. autoOpen: false,
  115. position: {my: 'top', at: 'bottom', of: '#weicano-entry'},
  116. }
  117. )
  118.  
  119. const keywords = Object(__WEBPACK_IMPORTED_MODULE_0__gm__["a" /* getKeywords */])()
  120. jqDlg.empty()
  121. keywords.map(([keyword,active], ind) => {
  122. const kwId = `weicano-kw-toggle-${ind}`
  123. jqDlg.append(
  124. $(`<div />`).css({
  125. width: '100%',
  126. display: 'flex',
  127. }).append(
  128. $('<label />').css({flex: 1}).prop({for: kwId}).text(keyword)
  129. ).append(
  130. $('<input />').prop(
  131. Object.assign(
  132. {type: 'checkbox', name: kwId, id: kwId},
  133. active ? {checked: true} : {}
  134. )
  135. ).change(() => {
  136. keywords[ind][1] = !keywords[ind][1]
  137. Object(__WEBPACK_IMPORTED_MODULE_0__gm__["c" /* setKeywords */])(keywords)
  138. applyFilters()
  139. mkDialogContent()
  140. })
  141. ).append(
  142. $('<button />').css({
  143. padding: 0,
  144. 'font-size': '10px',
  145. }).text('X').click(() => {
  146. const newKeywords = []
  147. keywords.map((x, xInd) => ind !== xInd && newKeywords.push(x))
  148. Object(__WEBPACK_IMPORTED_MODULE_0__gm__["c" /* setKeywords */])(newKeywords)
  149. applyFilters()
  150. mkDialogContent()
  151. })
  152. )
  153. )
  154. })
  155. jqDlg.append(
  156. $('<div />').css({width: '100%', display: 'flex'}).append(
  157. $('<input />').css({flex: 1}).prop({
  158. type: 'text',
  159. name: 'weicano-new-kw',
  160. id: 'weicano-new-kw',
  161. }).addClass('text ui-widget-content ui-corner-all')
  162. ).append(
  163. $('<button />').css({padding: 0, 'font-size': '10px'}).text('+').click(() => {
  164. const newKeyword = $('#weicano-dialog input#weicano-new-kw').val().trim()
  165. if (newKeyword) {
  166. $('#weicano-dialog input#weicano-new-kw').val('')
  167. Object(__WEBPACK_IMPORTED_MODULE_0__gm__["b" /* setKeyword */])(newKeyword)
  168. applyFilters()
  169. mkDialogContent()
  170. }
  171. })
  172. )
  173. )
  174.  
  175. $('#weicano-entry').text('Weicano').click(() => dlg.dialog('open'))
  176. }
  177.  
  178. document.documentElement.setAttribute('lang', 'zh-CN')
  179. $(document).ready(() => {
  180. $('head').append(
  181. $('<link/>').prop({
  182. rel: 'stylesheet',
  183. href: 'https://code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css',
  184. })
  185. )
  186. $("a#top:contains('广场')").parent().hide()
  187.  
  188. {
  189. const jq = $("a.nl:contains('话题')")
  190. jq.hide()
  191. jq[0].nextSibling.textContent = ''
  192.  
  193. jq.parent().append('|').append(
  194. $('<button id="weicano-entry" />')
  195. ).append(
  196. $('<div id="weicano-dialog" title="Weicano" />').hide()
  197. )
  198. }
  199.  
  200. $("a#top[href='http://m.weibo.cn']").parent().hide()
  201. $('div.pm > form span.pmf').hide()
  202.  
  203. applyFilters()
  204. mkDialogContent()
  205. })
  206.  
  207.  
  208. /***/ }),
  209. /* 1 */
  210. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  211.  
  212. "use strict";
  213. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return getKeywords; });
  214. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "b", function() { return setKeyword; });
  215. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "c", function() { return setKeywords; });
  216. const getKeywords = () =>
  217. JSON.parse(GM_getValue('keywords','[]'))
  218.  
  219. const setKeywords = keywords =>
  220. GM_setValue('keywords',JSON.stringify(keywords))
  221.  
  222. const setKeyword = (keyword, value=true) => {
  223. const keywords = getKeywords()
  224. const kwInd = keywords.findIndex(([kw]) => kw === keyword)
  225. if (kwInd === -1) {
  226. keywords.push([keyword,value])
  227. } else {
  228. keywords[kwInd][1] = value
  229. }
  230. setKeywords(keywords)
  231. }
  232.  
  233.  
  234.  
  235.  
  236. /***/ })
  237. /******/ ]);

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址