├── README.md ├── dist ├── block_posts.user.js ├── remove_baidu_redirect.user.js ├── remove_baidu_search_ads.user.js ├── remove_tieba_ads.user.js └── remove_zhihu_redirect.user.js ├── gulpfile.js ├── libs ├── $addStyle.js ├── $debounce.js ├── $http.js ├── $interval.js ├── $timeout.js ├── $util.js └── jqLite.js ├── package.json ├── scripts ├── block_posts.js ├── meta.js ├── remove_baidu_redirect.js ├── remove_baidu_search_ads.js ├── remove_tieba_ads.js └── remove_zhihu_redirect.js ├── src ├── block_posts │ ├── common.js │ ├── formatDate.js │ ├── icon.js │ ├── meta.js │ ├── panel.html │ ├── panel.js │ └── style.scss ├── remove_baidu_redirect │ ├── config.js │ ├── init.js │ ├── main.js │ ├── meta.js │ ├── mouseover.js │ ├── observe.js │ └── scroll.js ├── remove_baidu_search_ads │ ├── config.js │ ├── main.js │ └── meta.js ├── remove_tieba_ads │ ├── config.js │ ├── main.js │ └── meta.js └── remove_zhihu_redirect │ ├── main.js │ └── meta.js └── webpack.config.js /README.md: -------------------------------------------------------------------------------- 1 | ### 我的油猴脚本集合 2 | 3 | [![Greenkeeper badge](https://badges.greenkeeper.io/axetroy/GMscript.svg)](https://greenkeeper.io/) 4 | 5 | #### 当前脚本,点击直接安装 6 | 7 | - [去除百度搜索跳转链接es6](https://github.com/axetroy/GMscript/raw/master/dist/remove_baidu_redirect.user.js)(不推荐继续使用) 8 | - [去除百度搜索跳转链接typescript](https://github.com/axetroy/bd-fuck) 9 | - [去除百度搜索的置顶推广](https://github.com/axetroy/GMscript/raw/master/dist/remove_baidu_search_ads.user.js) 10 | - [去除百度贴吧的广告](https://github.com/axetroy/GMscript/raw/master/dist/remove_tieba_ads.user.js) 11 | - [去除知乎的跳转链接](https://github.com/axetroy/GMscript/raw/master/dist/remove_zhihu_redirect.user.js) 12 | - [贴吧屏蔽某人](https://github.com/axetroy/GMscript/raw/master/dist/block_posts.user.js) 13 | 14 | #### 目录结构 15 | 16 | ```bash 17 | - dist // 存放最终的输出脚本 18 | - libs // 公共库 19 | - scripts // 各脚本的入口文件 20 | - src // 各脚本的源代码 21 | - README.md 22 | - gulpfile.js 23 | - package.json 24 | - webpack.config.js 25 | ``` 26 | 27 | ### 项目构建 28 | 29 | ```bash 30 | npm install 31 | gulp build 32 | ``` 33 | -------------------------------------------------------------------------------- /dist/remove_baidu_search_ads.user.js: -------------------------------------------------------------------------------- 1 | // ==UserScript== 2 | // @name 去百度搜索置顶推广 (ECMA6) 3 | // @author axetroy 4 | // @contributor axetroy 5 | // @description 去除插入在百度搜索结果头部、尾部的推广链接。 6 | // @version 2016.6.4 7 | // @grant none 8 | // @include *www.baidu.com* 9 | // @include *zhidao.baidu.com/search* 10 | // @connect * 11 | // @supportURL http://www.burningall.com 12 | // @compatible chrome 完美运行 13 | // @compatible firefox 完美运行 14 | // @run-at document-start 15 | // @contributionURL troy450409405@gmail.com|alipay.com 16 | // @namespace https://greasyfork.org/zh-CN/users/3400-axetroy 17 | // @license The MIT License (MIT); http://opensource.org/licenses/MIT 18 | // ==/UserScript== 19 | 20 | /* 21 | 22 | Github源码:https://github.com/axetroy/GMscript 23 | 24 | */ 25 | /******/ (function(modules) { // webpackBootstrap 26 | /******/ // The module cache 27 | /******/ var installedModules = {}; 28 | 29 | /******/ // The require function 30 | /******/ function __webpack_require__(moduleId) { 31 | 32 | /******/ // Check if module is in cache 33 | /******/ if(installedModules[moduleId]) 34 | /******/ return installedModules[moduleId].exports; 35 | 36 | /******/ // Create a new module (and put it into the cache) 37 | /******/ var module = installedModules[moduleId] = { 38 | /******/ exports: {}, 39 | /******/ id: moduleId, 40 | /******/ loaded: false 41 | /******/ }; 42 | 43 | /******/ // Execute the module function 44 | /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); 45 | 46 | /******/ // Flag the module as loaded 47 | /******/ module.loaded = true; 48 | 49 | /******/ // Return the exports of the module 50 | /******/ return module.exports; 51 | /******/ } 52 | 53 | 54 | /******/ // expose the modules object (__webpack_modules__) 55 | /******/ __webpack_require__.m = modules; 56 | 57 | /******/ // expose the module cache 58 | /******/ __webpack_require__.c = installedModules; 59 | 60 | /******/ // __webpack_public_path__ 61 | /******/ __webpack_require__.p = ""; 62 | 63 | /******/ // Load entry module and return exports 64 | /******/ return __webpack_require__(0); 65 | /******/ }) 66 | /************************************************************************/ 67 | /******/ ([ 68 | /* 0 */ 69 | /***/ function(module, exports, __webpack_require__) { 70 | 71 | 'use strict'; 72 | 73 | var _jqLite = __webpack_require__(1); 74 | 75 | var _jqLite2 = _interopRequireDefault(_jqLite); 76 | 77 | var _$interval = __webpack_require__(55); 78 | 79 | var _$interval2 = _interopRequireDefault(_$interval); 80 | 81 | var _main = __webpack_require__(56); 82 | 83 | var _main2 = _interopRequireDefault(_main); 84 | 85 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 86 | 87 | var loop = (0, _$interval2.default)(function () { 88 | new _main2.default().filter().turn(); 89 | }, 50); 90 | 91 | // init 92 | (0, _jqLite2.default)(function () { 93 | new _main2.default().filter().turn(); 94 | _$interval2.default.cancel(loop); 95 | (0, _jqLite2.default)(document).observe(function () { 96 | return new _main2.default().filter().turn(); 97 | }); 98 | console.info('去广告启动...'); 99 | }); 100 | 101 | /***/ }, 102 | /* 1 */ 103 | /***/ function(module, exports, __webpack_require__) { 104 | 105 | 'use strict'; 106 | 107 | // es6 Array.from 108 | 109 | Object.defineProperty(exports, "__esModule", { 110 | value: true 111 | }); 112 | 113 | var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol ? "symbol" : typeof obj; }; 114 | 115 | var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); 116 | // es6 Object.assign 117 | 118 | 119 | __webpack_require__(2); 120 | 121 | __webpack_require__(30); 122 | 123 | function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } 124 | 125 | var noop = function noop(x) { 126 | return x; 127 | }; 128 | 129 | var jqLite = function () { 130 | function jqLite() { 131 | var _this = this; 132 | 133 | var selectors = arguments.length <= 0 || arguments[0] === undefined ? '' : arguments[0]; 134 | var context = arguments.length <= 1 || arguments[1] === undefined ? document : arguments[1]; 135 | 136 | _classCallCheck(this, jqLite); 137 | 138 | this.selectors = selectors; 139 | this.context = context; 140 | this.length = 0; 141 | 142 | switch (typeof selectors === 'undefined' ? 'undefined' : _typeof(selectors)) { 143 | case 'undefined': 144 | break; 145 | case 'string': 146 | Array.from(context.querySelectorAll(selectors), function (ele, i) { 147 | _this[i] = ele; 148 | _this.length++; 149 | }, this); 150 | break; 151 | case 'object': 152 | if (selectors.length) { 153 | Array.from(selectors, function (ele, i) { 154 | _this[i] = ele; 155 | _this.length++; 156 | }, this); 157 | } else { 158 | this[0] = selectors; 159 | this.length = 1; 160 | } 161 | break; 162 | case 'function': 163 | this.ready(selectors); 164 | break; 165 | default: 166 | 167 | } 168 | } 169 | 170 | _createClass(jqLite, [{ 171 | key: 'eq', 172 | value: function eq() { 173 | var n = arguments.length <= 0 || arguments[0] === undefined ? 0 : arguments[0]; 174 | 175 | return new jqLite(this[n]); 176 | } 177 | }, { 178 | key: 'find', 179 | value: function find(selectors) { 180 | return new jqLite(selectors, this[0]); 181 | } 182 | }, { 183 | key: 'each', 184 | value: function each() { 185 | var fn = arguments.length <= 0 || arguments[0] === undefined ? noop : arguments[0]; 186 | 187 | for (var i = 0; i < this.length; i++) { 188 | fn.call(this, this[i], i); 189 | } 190 | return this; 191 | } 192 | }, { 193 | key: 'bind', 194 | value: function bind() { 195 | var types = arguments.length <= 0 || arguments[0] === undefined ? '' : arguments[0]; 196 | var fn = arguments.length <= 1 || arguments[1] === undefined ? noop : arguments[1]; 197 | 198 | this.each(function (ele) { 199 | types.trim().split(/\s{1,}/).forEach(function (type) { 200 | ele.addEventListener(type, function (e) { 201 | var target = e.target || e.srcElement; 202 | if (fn.call(target, e) === false) { 203 | e.returnValue = true; 204 | e.cancelBubble = true; 205 | e.preventDefault && e.preventDefault(); 206 | e.stopPropagation && e.stopPropagation(); 207 | return false; 208 | } 209 | }, false); 210 | }); 211 | }); 212 | } 213 | }, { 214 | key: 'click', 215 | value: function click() { 216 | var fn = arguments.length <= 0 || arguments[0] === undefined ? noop : arguments[0]; 217 | 218 | this.bind('click', fn); 219 | return this; 220 | } 221 | }, { 222 | key: 'ready', 223 | value: function ready() { 224 | var _this2 = this; 225 | 226 | var fn = arguments.length <= 0 || arguments[0] === undefined ? noop : arguments[0]; 227 | 228 | window.addEventListener('DOMContentLoaded', function (e) { 229 | fn.call(_this2, e); 230 | }, false); 231 | } 232 | }, { 233 | key: 'observe', 234 | value: function observe() { 235 | var _this3 = this; 236 | 237 | var fn = arguments.length <= 0 || arguments[0] === undefined ? noop : arguments[0]; 238 | var config = arguments.length <= 1 || arguments[1] === undefined ? { childList: true, subtree: true } : arguments[1]; 239 | 240 | this.each(function (ele) { 241 | var MutationObserver = window.MutationObserver || window.WebKitMutationObserver || window.MozMutationObserver; 242 | var observer = new MutationObserver(function (mutations) { 243 | mutations.forEach(function (mutation) { 244 | fn.call(_this3, mutation.target, mutation.addedNodes, mutation.removedNodes); 245 | }); 246 | }); 247 | observer.observe(ele, config); 248 | }); 249 | return this; 250 | } 251 | }, { 252 | key: 'attr', 253 | value: function (_attr) { 254 | function attr(_x, _x2) { 255 | return _attr.apply(this, arguments); 256 | } 257 | 258 | attr.toString = function () { 259 | return _attr.toString(); 260 | }; 261 | 262 | return attr; 263 | }(function (attr, value) { 264 | // one agm 265 | if (arguments.length === 1) { 266 | // get attr value 267 | if (typeof attr === 'string') { 268 | return this[0].getAttribute(attr); 269 | } 270 | // set attr with a json 271 | else if ((typeof attr === 'undefined' ? 'undefined' : _typeof(attr)) === 'object') { 272 | this.each(function (ele) { 273 | for (var at in attr) { 274 | if (attr.hasOwnProperty(at)) { 275 | ele.setAttribute(at, value); 276 | } 277 | } 278 | }); 279 | return value; 280 | } 281 | } 282 | // set 283 | else if (arguments.length === 2) { 284 | this.each(function (ele) { 285 | ele.setAttribute(attr, value); 286 | }); 287 | return this; 288 | } else { 289 | return this; 290 | } 291 | }) 292 | }, { 293 | key: 'removeAttr', 294 | value: function removeAttr(attr) { 295 | if (arguments.length === 1) { 296 | this.each(function (ele) { 297 | ele.removeAttribute(attr); 298 | }); 299 | } 300 | return this; 301 | } 302 | }, { 303 | key: 'remove', 304 | value: function remove() { 305 | this.each(function (ele) { 306 | ele.remove(); 307 | }); 308 | this.length = 0; 309 | return this; 310 | } 311 | 312 | // get the element style 313 | 314 | }, { 315 | key: 'style', 316 | value: function style(attr) { 317 | return this[0].currentStyle ? this[0].currentStyle[attr] : getComputedStyle(this[0])[attr]; 318 | } 319 | 320 | // (attr,value) || 'string' || {} 321 | 322 | }, { 323 | key: 'css', 324 | value: function css() { 325 | for (var _len = arguments.length, agm = Array(_len), _key = 0; _key < _len; _key++) { 326 | agm[_key] = arguments[_key]; 327 | } 328 | 329 | if (agm.length === 1) { 330 | // get style 331 | if (typeof agm[0] === 'string') { 332 | // set style as a long text 333 | if (/:/ig.test(agm[0])) { 334 | this.each(function (ele) { 335 | ele.style.cssText = attr; 336 | }); 337 | } else { 338 | return this[0].currentStyle ? this[0].currentStyle[agm[0]] : getComputedStyle(this[0])[agm[0]]; 339 | } 340 | } 341 | // set style as a object 342 | else { 343 | this.each(function (ele) { 344 | for (var _attr2 in agm[0]) { 345 | if (agm[0].hasOwnProperty(_attr2)) { 346 | ele.style[_attr2] = agm[0][_attr2]; 347 | } 348 | } 349 | }); 350 | } 351 | } 352 | // set as (key,value) 353 | else if (agm.length === 2) { 354 | this.each(function (ele) { 355 | ele.style[agm[0]] = agm[1]; 356 | }); 357 | } 358 | return this; 359 | } 360 | }, { 361 | key: 'width', 362 | value: function width(value) { 363 | var element = this[0]; 364 | // window or document 365 | if (element.window === element || element.body) { 366 | return document.body.scrollWidth > document.documentElement.scrollWidth ? document.body.scrollWidth : document.documentElement.scrollWidth; 367 | } 368 | // set width 369 | else if (value) { 370 | this.each(function (ele) { 371 | ele.style.width = value + 'px'; 372 | }); 373 | return this; 374 | } 375 | // get width 376 | else { 377 | return this[0].offsetWidth || parseFloat(this.style('width')); 378 | } 379 | } 380 | }, { 381 | key: 'height', 382 | value: function height(value) { 383 | var ele = this[0]; 384 | // window or document 385 | if (ele.window === ele || ele.body) { 386 | return document.body.scrollHeight > document.documentElement.scrollHeight ? document.body.scrollHeight : document.documentElement.scrollHeight; 387 | } 388 | // set height 389 | else if (value) { 390 | this.each(function (ele) { 391 | ele.style.height = value + 'px'; 392 | }); 393 | return this; 394 | } 395 | // get height 396 | else { 397 | return this[0].offsetHeight || parseFloat(this.style('height')); 398 | } 399 | } 400 | }, { 401 | key: 'html', 402 | value: function html(value) { 403 | if (value !== undefined) { 404 | this.each(function (ele) { 405 | ele.innerHTML = typeof value === 'function' ? value(ele) : value; 406 | }); 407 | } else { 408 | return this[0].innerHTML; 409 | } 410 | return this; 411 | } 412 | }, { 413 | key: 'text', 414 | value: function text(value) { 415 | if (value === undefined) return this[0].innerText || this[0].textContent; 416 | 417 | this.each(function (ele) { 418 | ele.innerText = ele.textContent = value; 419 | }); 420 | return this; 421 | } 422 | }, { 423 | key: 'val', 424 | value: function val(value) { 425 | if (value === undefined) return this[0].value; 426 | this.each(function (ele) { 427 | ele.value = value; 428 | }); 429 | return this; 430 | } 431 | }, { 432 | key: 'show', 433 | value: function show() { 434 | this.each(function (ele) { 435 | ele.style.display = ''; 436 | }); 437 | return this; 438 | } 439 | }, { 440 | key: 'hide', 441 | value: function hide() { 442 | this.each(function (ele) { 443 | ele.style.display = 'none'; 444 | }); 445 | return this; 446 | } 447 | 448 | // content str || jqLite Object || DOM 449 | // here is jqLite Object 450 | 451 | }, { 452 | key: 'append', 453 | value: function append(content) { 454 | this.each(function (ele) { 455 | ele.appendChild(content[0]); 456 | }); 457 | return this; 458 | } 459 | }, { 460 | key: 'prepend', 461 | 462 | 463 | // content str || jqLite Object || DOM 464 | // here is jqLite Object 465 | value: function prepend(content) { 466 | this.each(function (ele) { 467 | ele.insertBefore(content[0], ele.children[0]); 468 | }); 469 | return this; 470 | } 471 | }, { 472 | key: 'hasClass', 473 | value: function hasClass(className) { 474 | if (!this[0]) return false; 475 | return this[0].classList.contains(className); 476 | } 477 | }, { 478 | key: 'addClass', 479 | value: function addClass(className) { 480 | this.each(function (ele) { 481 | ele.classList.add(className); 482 | }); 483 | return this; 484 | } 485 | }, { 486 | key: 'removeClass', 487 | value: function removeClass(className) { 488 | this.each(function (ele) { 489 | ele.classList.remove(className); 490 | }); 491 | return this; 492 | } 493 | }, { 494 | key: 'index', 495 | get: function get() { 496 | var index = 0; 497 | var brothers = this[0].parentNode.children; 498 | for (var i = 0; i < brothers.length; i++) { 499 | if (brothers[i] == this[0]) { 500 | index = i; 501 | break; 502 | } 503 | } 504 | return index; 505 | } 506 | }], [{ 507 | key: 'fn', 508 | get: function get() { 509 | var visible = function visible(ele) { 510 | var pos = ele.getBoundingClientRect(); 511 | var w = void 0; 512 | var h = void 0; 513 | var inViewPort = void 0; 514 | var docEle = document.documentElement; 515 | var docBody = document.body; 516 | if (docEle.getBoundingClientRect) { 517 | w = docEle.clientWidth || docBody.clientWidth; 518 | h = docEle.clientHeight || docBody.clientHeight; 519 | inViewPort = pos.top > h || pos.bottom < 0 || pos.left > w || pos.right < 0; 520 | return inViewPort ? false : true; 521 | } 522 | }; 523 | var merge = function merge() { 524 | for (var _len2 = arguments.length, sources = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { 525 | sources[_key2] = arguments[_key2]; 526 | } 527 | 528 | return Object.assign.apply(Object, [{}].concat(sources)); 529 | }; 530 | return { 531 | visible: visible, 532 | merge: merge 533 | }; 534 | } 535 | }]); 536 | 537 | return jqLite; 538 | }(); 539 | 540 | var $ = function $() { 541 | var selectors = arguments.length <= 0 || arguments[0] === undefined ? '' : arguments[0]; 542 | var context = arguments.length <= 1 || arguments[1] === undefined ? document : arguments[1]; 543 | 544 | return new jqLite(selectors, context); 545 | }; 546 | $.fn = jqLite.fn; 547 | 548 | exports.default = $; 549 | 550 | /***/ }, 551 | /* 2 */ 552 | /***/ function(module, exports, __webpack_require__) { 553 | 554 | 'use strict'; 555 | var ctx = __webpack_require__(3) 556 | , $export = __webpack_require__(5) 557 | , toObject = __webpack_require__(15) 558 | , call = __webpack_require__(17) 559 | , isArrayIter = __webpack_require__(20) 560 | , toLength = __webpack_require__(24) 561 | , getIterFn = __webpack_require__(26); 562 | $export($export.S + $export.F * !__webpack_require__(29)(function(iter){ Array.from(iter); }), 'Array', { 563 | // 22.1.2.1 Array.from(arrayLike, mapfn = undefined, thisArg = undefined) 564 | from: function from(arrayLike/*, mapfn = undefined, thisArg = undefined*/){ 565 | var O = toObject(arrayLike) 566 | , C = typeof this == 'function' ? this : Array 567 | , $$ = arguments 568 | , $$len = $$.length 569 | , mapfn = $$len > 1 ? $$[1] : undefined 570 | , mapping = mapfn !== undefined 571 | , index = 0 572 | , iterFn = getIterFn(O) 573 | , length, result, step, iterator; 574 | if(mapping)mapfn = ctx(mapfn, $$len > 2 ? $$[2] : undefined, 2); 575 | // if object isn't iterable or it's array with default iterator - use simple case 576 | if(iterFn != undefined && !(C == Array && isArrayIter(iterFn))){ 577 | for(iterator = iterFn.call(O), result = new C; !(step = iterator.next()).done; index++){ 578 | result[index] = mapping ? call(iterator, mapfn, [step.value, index], true) : step.value; 579 | } 580 | } else { 581 | length = toLength(O.length); 582 | for(result = new C(length); length > index; index++){ 583 | result[index] = mapping ? mapfn(O[index], index) : O[index]; 584 | } 585 | } 586 | result.length = index; 587 | return result; 588 | } 589 | }); 590 | 591 | 592 | /***/ }, 593 | /* 3 */ 594 | /***/ function(module, exports, __webpack_require__) { 595 | 596 | // optional / simple context binding 597 | var aFunction = __webpack_require__(4); 598 | module.exports = function(fn, that, length){ 599 | aFunction(fn); 600 | if(that === undefined)return fn; 601 | switch(length){ 602 | case 1: return function(a){ 603 | return fn.call(that, a); 604 | }; 605 | case 2: return function(a, b){ 606 | return fn.call(that, a, b); 607 | }; 608 | case 3: return function(a, b, c){ 609 | return fn.call(that, a, b, c); 610 | }; 611 | } 612 | return function(/* ...args */){ 613 | return fn.apply(that, arguments); 614 | }; 615 | }; 616 | 617 | /***/ }, 618 | /* 4 */ 619 | /***/ function(module, exports) { 620 | 621 | module.exports = function(it){ 622 | if(typeof it != 'function')throw TypeError(it + ' is not a function!'); 623 | return it; 624 | }; 625 | 626 | /***/ }, 627 | /* 5 */ 628 | /***/ function(module, exports, __webpack_require__) { 629 | 630 | var global = __webpack_require__(6) 631 | , core = __webpack_require__(7) 632 | , hide = __webpack_require__(8) 633 | , redefine = __webpack_require__(13) 634 | , ctx = __webpack_require__(3) 635 | , PROTOTYPE = 'prototype'; 636 | 637 | var $export = function(type, name, source){ 638 | var IS_FORCED = type & $export.F 639 | , IS_GLOBAL = type & $export.G 640 | , IS_STATIC = type & $export.S 641 | , IS_PROTO = type & $export.P 642 | , IS_BIND = type & $export.B 643 | , target = IS_GLOBAL ? global : IS_STATIC ? global[name] || (global[name] = {}) : (global[name] || {})[PROTOTYPE] 644 | , exports = IS_GLOBAL ? core : core[name] || (core[name] = {}) 645 | , expProto = exports[PROTOTYPE] || (exports[PROTOTYPE] = {}) 646 | , key, own, out, exp; 647 | if(IS_GLOBAL)source = name; 648 | for(key in source){ 649 | // contains in native 650 | own = !IS_FORCED && target && key in target; 651 | // export native or passed 652 | out = (own ? target : source)[key]; 653 | // bind timers to global for call from export context 654 | exp = IS_BIND && own ? ctx(out, global) : IS_PROTO && typeof out == 'function' ? ctx(Function.call, out) : out; 655 | // extend global 656 | if(target && !own)redefine(target, key, out); 657 | // export 658 | if(exports[key] != out)hide(exports, key, exp); 659 | if(IS_PROTO && expProto[key] != out)expProto[key] = out; 660 | } 661 | }; 662 | global.core = core; 663 | // type bitmap 664 | $export.F = 1; // forced 665 | $export.G = 2; // global 666 | $export.S = 4; // static 667 | $export.P = 8; // proto 668 | $export.B = 16; // bind 669 | $export.W = 32; // wrap 670 | module.exports = $export; 671 | 672 | /***/ }, 673 | /* 6 */ 674 | /***/ function(module, exports) { 675 | 676 | // https://github.com/zloirock/core-js/issues/86#issuecomment-115759028 677 | var global = module.exports = typeof window != 'undefined' && window.Math == Math 678 | ? window : typeof self != 'undefined' && self.Math == Math ? self : Function('return this')(); 679 | if(typeof __g == 'number')__g = global; // eslint-disable-line no-undef 680 | 681 | /***/ }, 682 | /* 7 */ 683 | /***/ function(module, exports) { 684 | 685 | var core = module.exports = {version: '1.2.6'}; 686 | if(typeof __e == 'number')__e = core; // eslint-disable-line no-undef 687 | 688 | /***/ }, 689 | /* 8 */ 690 | /***/ function(module, exports, __webpack_require__) { 691 | 692 | var $ = __webpack_require__(9) 693 | , createDesc = __webpack_require__(10); 694 | module.exports = __webpack_require__(11) ? function(object, key, value){ 695 | return $.setDesc(object, key, createDesc(1, value)); 696 | } : function(object, key, value){ 697 | object[key] = value; 698 | return object; 699 | }; 700 | 701 | /***/ }, 702 | /* 9 */ 703 | /***/ function(module, exports) { 704 | 705 | var $Object = Object; 706 | module.exports = { 707 | create: $Object.create, 708 | getProto: $Object.getPrototypeOf, 709 | isEnum: {}.propertyIsEnumerable, 710 | getDesc: $Object.getOwnPropertyDescriptor, 711 | setDesc: $Object.defineProperty, 712 | setDescs: $Object.defineProperties, 713 | getKeys: $Object.keys, 714 | getNames: $Object.getOwnPropertyNames, 715 | getSymbols: $Object.getOwnPropertySymbols, 716 | each: [].forEach 717 | }; 718 | 719 | /***/ }, 720 | /* 10 */ 721 | /***/ function(module, exports) { 722 | 723 | module.exports = function(bitmap, value){ 724 | return { 725 | enumerable : !(bitmap & 1), 726 | configurable: !(bitmap & 2), 727 | writable : !(bitmap & 4), 728 | value : value 729 | }; 730 | }; 731 | 732 | /***/ }, 733 | /* 11 */ 734 | /***/ function(module, exports, __webpack_require__) { 735 | 736 | // Thank's IE8 for his funny defineProperty 737 | module.exports = !__webpack_require__(12)(function(){ 738 | return Object.defineProperty({}, 'a', {get: function(){ return 7; }}).a != 7; 739 | }); 740 | 741 | /***/ }, 742 | /* 12 */ 743 | /***/ function(module, exports) { 744 | 745 | module.exports = function(exec){ 746 | try { 747 | return !!exec(); 748 | } catch(e){ 749 | return true; 750 | } 751 | }; 752 | 753 | /***/ }, 754 | /* 13 */ 755 | /***/ function(module, exports, __webpack_require__) { 756 | 757 | // add fake Function#toString 758 | // for correct work wrapped methods / constructors with methods like LoDash isNative 759 | var global = __webpack_require__(6) 760 | , hide = __webpack_require__(8) 761 | , SRC = __webpack_require__(14)('src') 762 | , TO_STRING = 'toString' 763 | , $toString = Function[TO_STRING] 764 | , TPL = ('' + $toString).split(TO_STRING); 765 | 766 | __webpack_require__(7).inspectSource = function(it){ 767 | return $toString.call(it); 768 | }; 769 | 770 | (module.exports = function(O, key, val, safe){ 771 | if(typeof val == 'function'){ 772 | val.hasOwnProperty(SRC) || hide(val, SRC, O[key] ? '' + O[key] : TPL.join(String(key))); 773 | val.hasOwnProperty('name') || hide(val, 'name', key); 774 | } 775 | if(O === global){ 776 | O[key] = val; 777 | } else { 778 | if(!safe)delete O[key]; 779 | hide(O, key, val); 780 | } 781 | })(Function.prototype, TO_STRING, function toString(){ 782 | return typeof this == 'function' && this[SRC] || $toString.call(this); 783 | }); 784 | 785 | /***/ }, 786 | /* 14 */ 787 | /***/ function(module, exports) { 788 | 789 | var id = 0 790 | , px = Math.random(); 791 | module.exports = function(key){ 792 | return 'Symbol('.concat(key === undefined ? '' : key, ')_', (++id + px).toString(36)); 793 | }; 794 | 795 | /***/ }, 796 | /* 15 */ 797 | /***/ function(module, exports, __webpack_require__) { 798 | 799 | // 7.1.13 ToObject(argument) 800 | var defined = __webpack_require__(16); 801 | module.exports = function(it){ 802 | return Object(defined(it)); 803 | }; 804 | 805 | /***/ }, 806 | /* 16 */ 807 | /***/ function(module, exports) { 808 | 809 | // 7.2.1 RequireObjectCoercible(argument) 810 | module.exports = function(it){ 811 | if(it == undefined)throw TypeError("Can't call method on " + it); 812 | return it; 813 | }; 814 | 815 | /***/ }, 816 | /* 17 */ 817 | /***/ function(module, exports, __webpack_require__) { 818 | 819 | // call something on iterator step with safe closing on error 820 | var anObject = __webpack_require__(18); 821 | module.exports = function(iterator, fn, value, entries){ 822 | try { 823 | return entries ? fn(anObject(value)[0], value[1]) : fn(value); 824 | // 7.4.6 IteratorClose(iterator, completion) 825 | } catch(e){ 826 | var ret = iterator['return']; 827 | if(ret !== undefined)anObject(ret.call(iterator)); 828 | throw e; 829 | } 830 | }; 831 | 832 | /***/ }, 833 | /* 18 */ 834 | /***/ function(module, exports, __webpack_require__) { 835 | 836 | var isObject = __webpack_require__(19); 837 | module.exports = function(it){ 838 | if(!isObject(it))throw TypeError(it + ' is not an object!'); 839 | return it; 840 | }; 841 | 842 | /***/ }, 843 | /* 19 */ 844 | /***/ function(module, exports) { 845 | 846 | module.exports = function(it){ 847 | return typeof it === 'object' ? it !== null : typeof it === 'function'; 848 | }; 849 | 850 | /***/ }, 851 | /* 20 */ 852 | /***/ function(module, exports, __webpack_require__) { 853 | 854 | // check on default Array iterator 855 | var Iterators = __webpack_require__(21) 856 | , ITERATOR = __webpack_require__(22)('iterator') 857 | , ArrayProto = Array.prototype; 858 | 859 | module.exports = function(it){ 860 | return it !== undefined && (Iterators.Array === it || ArrayProto[ITERATOR] === it); 861 | }; 862 | 863 | /***/ }, 864 | /* 21 */ 865 | /***/ function(module, exports) { 866 | 867 | module.exports = {}; 868 | 869 | /***/ }, 870 | /* 22 */ 871 | /***/ function(module, exports, __webpack_require__) { 872 | 873 | var store = __webpack_require__(23)('wks') 874 | , uid = __webpack_require__(14) 875 | , Symbol = __webpack_require__(6).Symbol; 876 | module.exports = function(name){ 877 | return store[name] || (store[name] = 878 | Symbol && Symbol[name] || (Symbol || uid)('Symbol.' + name)); 879 | }; 880 | 881 | /***/ }, 882 | /* 23 */ 883 | /***/ function(module, exports, __webpack_require__) { 884 | 885 | var global = __webpack_require__(6) 886 | , SHARED = '__core-js_shared__' 887 | , store = global[SHARED] || (global[SHARED] = {}); 888 | module.exports = function(key){ 889 | return store[key] || (store[key] = {}); 890 | }; 891 | 892 | /***/ }, 893 | /* 24 */ 894 | /***/ function(module, exports, __webpack_require__) { 895 | 896 | // 7.1.15 ToLength 897 | var toInteger = __webpack_require__(25) 898 | , min = Math.min; 899 | module.exports = function(it){ 900 | return it > 0 ? min(toInteger(it), 0x1fffffffffffff) : 0; // pow(2, 53) - 1 == 9007199254740991 901 | }; 902 | 903 | /***/ }, 904 | /* 25 */ 905 | /***/ function(module, exports) { 906 | 907 | // 7.1.4 ToInteger 908 | var ceil = Math.ceil 909 | , floor = Math.floor; 910 | module.exports = function(it){ 911 | return isNaN(it = +it) ? 0 : (it > 0 ? floor : ceil)(it); 912 | }; 913 | 914 | /***/ }, 915 | /* 26 */ 916 | /***/ function(module, exports, __webpack_require__) { 917 | 918 | var classof = __webpack_require__(27) 919 | , ITERATOR = __webpack_require__(22)('iterator') 920 | , Iterators = __webpack_require__(21); 921 | module.exports = __webpack_require__(7).getIteratorMethod = function(it){ 922 | if(it != undefined)return it[ITERATOR] 923 | || it['@@iterator'] 924 | || Iterators[classof(it)]; 925 | }; 926 | 927 | /***/ }, 928 | /* 27 */ 929 | /***/ function(module, exports, __webpack_require__) { 930 | 931 | // getting tag from 19.1.3.6 Object.prototype.toString() 932 | var cof = __webpack_require__(28) 933 | , TAG = __webpack_require__(22)('toStringTag') 934 | // ES3 wrong here 935 | , ARG = cof(function(){ return arguments; }()) == 'Arguments'; 936 | 937 | module.exports = function(it){ 938 | var O, T, B; 939 | return it === undefined ? 'Undefined' : it === null ? 'Null' 940 | // @@toStringTag case 941 | : typeof (T = (O = Object(it))[TAG]) == 'string' ? T 942 | // builtinTag case 943 | : ARG ? cof(O) 944 | // ES3 arguments fallback 945 | : (B = cof(O)) == 'Object' && typeof O.callee == 'function' ? 'Arguments' : B; 946 | }; 947 | 948 | /***/ }, 949 | /* 28 */ 950 | /***/ function(module, exports) { 951 | 952 | var toString = {}.toString; 953 | 954 | module.exports = function(it){ 955 | return toString.call(it).slice(8, -1); 956 | }; 957 | 958 | /***/ }, 959 | /* 29 */ 960 | /***/ function(module, exports, __webpack_require__) { 961 | 962 | var ITERATOR = __webpack_require__(22)('iterator') 963 | , SAFE_CLOSING = false; 964 | 965 | try { 966 | var riter = [7][ITERATOR](); 967 | riter['return'] = function(){ SAFE_CLOSING = true; }; 968 | Array.from(riter, function(){ throw 2; }); 969 | } catch(e){ /* empty */ } 970 | 971 | module.exports = function(exec, skipClosing){ 972 | if(!skipClosing && !SAFE_CLOSING)return false; 973 | var safe = false; 974 | try { 975 | var arr = [7] 976 | , iter = arr[ITERATOR](); 977 | iter.next = function(){ safe = true; }; 978 | arr[ITERATOR] = function(){ return iter; }; 979 | exec(arr); 980 | } catch(e){ /* empty */ } 981 | return safe; 982 | }; 983 | 984 | /***/ }, 985 | /* 30 */ 986 | /***/ function(module, exports, __webpack_require__) { 987 | 988 | // 19.1.3.1 Object.assign(target, source) 989 | var $export = __webpack_require__(5); 990 | 991 | $export($export.S + $export.F, 'Object', {assign: __webpack_require__(31)}); 992 | 993 | /***/ }, 994 | /* 31 */ 995 | /***/ function(module, exports, __webpack_require__) { 996 | 997 | // 19.1.2.1 Object.assign(target, source, ...) 998 | var $ = __webpack_require__(9) 999 | , toObject = __webpack_require__(15) 1000 | , IObject = __webpack_require__(32); 1001 | 1002 | // should work with symbols and should have deterministic property order (V8 bug) 1003 | module.exports = __webpack_require__(12)(function(){ 1004 | var a = Object.assign 1005 | , A = {} 1006 | , B = {} 1007 | , S = Symbol() 1008 | , K = 'abcdefghijklmnopqrst'; 1009 | A[S] = 7; 1010 | K.split('').forEach(function(k){ B[k] = k; }); 1011 | return a({}, A)[S] != 7 || Object.keys(a({}, B)).join('') != K; 1012 | }) ? function assign(target, source){ // eslint-disable-line no-unused-vars 1013 | var T = toObject(target) 1014 | , $$ = arguments 1015 | , $$len = $$.length 1016 | , index = 1 1017 | , getKeys = $.getKeys 1018 | , getSymbols = $.getSymbols 1019 | , isEnum = $.isEnum; 1020 | while($$len > index){ 1021 | var S = IObject($$[index++]) 1022 | , keys = getSymbols ? getKeys(S).concat(getSymbols(S)) : getKeys(S) 1023 | , length = keys.length 1024 | , j = 0 1025 | , key; 1026 | while(length > j)if(isEnum.call(S, key = keys[j++]))T[key] = S[key]; 1027 | } 1028 | return T; 1029 | } : Object.assign; 1030 | 1031 | /***/ }, 1032 | /* 32 */ 1033 | /***/ function(module, exports, __webpack_require__) { 1034 | 1035 | // fallback for non-array-like ES3 and non-enumerable old V8 strings 1036 | var cof = __webpack_require__(28); 1037 | module.exports = Object('z').propertyIsEnumerable(0) ? Object : function(it){ 1038 | return cof(it) == 'String' ? it.split('') : Object(it); 1039 | }; 1040 | 1041 | /***/ }, 1042 | /* 33 */, 1043 | /* 34 */, 1044 | /* 35 */, 1045 | /* 36 */, 1046 | /* 37 */, 1047 | /* 38 */, 1048 | /* 39 */, 1049 | /* 40 */, 1050 | /* 41 */, 1051 | /* 42 */, 1052 | /* 43 */, 1053 | /* 44 */, 1054 | /* 45 */, 1055 | /* 46 */, 1056 | /* 47 */, 1057 | /* 48 */, 1058 | /* 49 */, 1059 | /* 50 */, 1060 | /* 51 */, 1061 | /* 52 */, 1062 | /* 53 */, 1063 | /* 54 */, 1064 | /* 55 */ 1065 | /***/ function(module, exports) { 1066 | 1067 | "use strict"; 1068 | 1069 | Object.defineProperty(exports, "__esModule", { 1070 | value: true 1071 | }); 1072 | var $interval = function $interval(fn, delay) { 1073 | var interval = function interval() { 1074 | fn.call(undefined); 1075 | id = setTimeout(interval, delay); 1076 | }; 1077 | 1078 | var id = setTimeout(interval, delay); 1079 | 1080 | return function () { 1081 | window.clearTimeout(id); 1082 | }; 1083 | }; 1084 | 1085 | $interval.cancel = function (timerFunc) { 1086 | timerFunc(); 1087 | }; 1088 | 1089 | exports.default = $interval; 1090 | 1091 | /***/ }, 1092 | /* 56 */ 1093 | /***/ function(module, exports, __webpack_require__) { 1094 | 1095 | 'use strict'; 1096 | 1097 | Object.defineProperty(exports, "__esModule", { 1098 | value: true 1099 | }); 1100 | 1101 | var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); 1102 | 1103 | var _jqLite = __webpack_require__(1); 1104 | 1105 | var _jqLite2 = _interopRequireDefault(_jqLite); 1106 | 1107 | var _config = __webpack_require__(57); 1108 | 1109 | var _config2 = _interopRequireDefault(_config); 1110 | 1111 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 1112 | 1113 | function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } 1114 | 1115 | var Main = function () { 1116 | function Main() { 1117 | var rules = arguments.length <= 0 || arguments[0] === undefined ? _config2.default.rules : arguments[0]; 1118 | 1119 | _classCallCheck(this, Main); 1120 | 1121 | this.ads = (0, _jqLite2.default)(rules); 1122 | this.length = this.ads.length; 1123 | } 1124 | 1125 | _createClass(Main, [{ 1126 | key: 'filter', 1127 | value: function filter() { 1128 | this.ads.each(function (ele, i) { 1129 | ele.style.cssText = '\n display:none !important;\n visibility:hidden !important;\n width:0 !important;\n height:0 !important;\n overflow:hidden !important;\n // background-color:red !important;\n // border:1px solid red;\n '; 1130 | ele.setAttribute('filtered', ''); 1131 | }); 1132 | return this; 1133 | } 1134 | }, { 1135 | key: 'turn', 1136 | value: function turn() { 1137 | (0, _jqLite2.default)('#content_left input[type=checkbox]:not(filtered)').each(function (ele) { 1138 | ele.checked = false; 1139 | ele.setAttribute('filtered', ''); 1140 | }); 1141 | return this; 1142 | } 1143 | }]); 1144 | 1145 | return Main; 1146 | }(); 1147 | 1148 | exports.default = Main; 1149 | 1150 | /***/ }, 1151 | /* 57 */ 1152 | /***/ function(module, exports) { 1153 | 1154 | 'use strict'; 1155 | 1156 | Object.defineProperty(exports, "__esModule", { 1157 | value: true 1158 | }); 1159 | var CONFIG = { 1160 | rules: '\n #content_left>div\n :not([class*=result])\n :not([class*=container])\n :not(.leftBlock)\n :not(#rs_top_new)\n :not([filtered])\n ,\n #content_left>table\n :not(.result)\n :not([filtered])\n ,\n #content_right>table td\n div#ec_im_container\n ,\n div.s-news-list-wrapper>div\n :not([data-relatewords*="1"])\n ,\n div.list-wraper dl[data-oad]\n :not([data-fb])\n :not([filtered])\n '.trim().replace(/\n/img, '').replace(/\s{1,}([^a-zA-Z])/g, '$1') 1161 | }; 1162 | 1163 | exports.default = CONFIG; 1164 | 1165 | /***/ } 1166 | /******/ ]); -------------------------------------------------------------------------------- /dist/remove_tieba_ads.user.js: -------------------------------------------------------------------------------- 1 | // ==UserScript== 2 | // @name 去除贴吧列表里面的广告 3 | // @author axetroy 4 | // @description 去除贴吧掺夹在[帖子列表][回复列表]里的广告 5 | // @version 2016.6.4 6 | // @include http://tieba.baidu.com/* 7 | // @connect tags 8 | // @connect * 9 | // @compatible chrome 完美运行 10 | // @compatible firefox 完美运行 11 | // @supportURL http://www.burningall.com 12 | // @run-at document-start 13 | // @contributionURL troy450409405@gmail.com|alipay.com 14 | // @namespace https://greasyfork.org/zh-CN/users/3400-axetroy 15 | // @license The MIT License (MIT); http://opensource.org/licenses/MIT 16 | // ==/UserScript== 17 | 18 | /* 19 | 20 | Github源码:https://github.com/axetroy/GMscript 21 | 22 | */ 23 | /******/ (function(modules) { // webpackBootstrap 24 | /******/ // The module cache 25 | /******/ var installedModules = {}; 26 | 27 | /******/ // The require function 28 | /******/ function __webpack_require__(moduleId) { 29 | 30 | /******/ // Check if module is in cache 31 | /******/ if(installedModules[moduleId]) 32 | /******/ return installedModules[moduleId].exports; 33 | 34 | /******/ // Create a new module (and put it into the cache) 35 | /******/ var module = installedModules[moduleId] = { 36 | /******/ exports: {}, 37 | /******/ id: moduleId, 38 | /******/ loaded: false 39 | /******/ }; 40 | 41 | /******/ // Execute the module function 42 | /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); 43 | 44 | /******/ // Flag the module as loaded 45 | /******/ module.loaded = true; 46 | 47 | /******/ // Return the exports of the module 48 | /******/ return module.exports; 49 | /******/ } 50 | 51 | 52 | /******/ // expose the modules object (__webpack_modules__) 53 | /******/ __webpack_require__.m = modules; 54 | 55 | /******/ // expose the module cache 56 | /******/ __webpack_require__.c = installedModules; 57 | 58 | /******/ // __webpack_public_path__ 59 | /******/ __webpack_require__.p = ""; 60 | 61 | /******/ // Load entry module and return exports 62 | /******/ return __webpack_require__(0); 63 | /******/ }) 64 | /************************************************************************/ 65 | /******/ ([ 66 | /* 0 */ 67 | /***/ function(module, exports, __webpack_require__) { 68 | 69 | 'use strict'; 70 | 71 | __webpack_require__(58); 72 | 73 | /***/ }, 74 | /* 1 */ 75 | /***/ function(module, exports, __webpack_require__) { 76 | 77 | 'use strict'; 78 | 79 | // es6 Array.from 80 | 81 | Object.defineProperty(exports, "__esModule", { 82 | value: true 83 | }); 84 | 85 | var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol ? "symbol" : typeof obj; }; 86 | 87 | var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); 88 | // es6 Object.assign 89 | 90 | 91 | __webpack_require__(2); 92 | 93 | __webpack_require__(30); 94 | 95 | function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } 96 | 97 | var noop = function noop(x) { 98 | return x; 99 | }; 100 | 101 | var jqLite = function () { 102 | function jqLite() { 103 | var _this = this; 104 | 105 | var selectors = arguments.length <= 0 || arguments[0] === undefined ? '' : arguments[0]; 106 | var context = arguments.length <= 1 || arguments[1] === undefined ? document : arguments[1]; 107 | 108 | _classCallCheck(this, jqLite); 109 | 110 | this.selectors = selectors; 111 | this.context = context; 112 | this.length = 0; 113 | 114 | switch (typeof selectors === 'undefined' ? 'undefined' : _typeof(selectors)) { 115 | case 'undefined': 116 | break; 117 | case 'string': 118 | Array.from(context.querySelectorAll(selectors), function (ele, i) { 119 | _this[i] = ele; 120 | _this.length++; 121 | }, this); 122 | break; 123 | case 'object': 124 | if (selectors.length) { 125 | Array.from(selectors, function (ele, i) { 126 | _this[i] = ele; 127 | _this.length++; 128 | }, this); 129 | } else { 130 | this[0] = selectors; 131 | this.length = 1; 132 | } 133 | break; 134 | case 'function': 135 | this.ready(selectors); 136 | break; 137 | default: 138 | 139 | } 140 | } 141 | 142 | _createClass(jqLite, [{ 143 | key: 'eq', 144 | value: function eq() { 145 | var n = arguments.length <= 0 || arguments[0] === undefined ? 0 : arguments[0]; 146 | 147 | return new jqLite(this[n]); 148 | } 149 | }, { 150 | key: 'find', 151 | value: function find(selectors) { 152 | return new jqLite(selectors, this[0]); 153 | } 154 | }, { 155 | key: 'each', 156 | value: function each() { 157 | var fn = arguments.length <= 0 || arguments[0] === undefined ? noop : arguments[0]; 158 | 159 | for (var i = 0; i < this.length; i++) { 160 | fn.call(this, this[i], i); 161 | } 162 | return this; 163 | } 164 | }, { 165 | key: 'bind', 166 | value: function bind() { 167 | var types = arguments.length <= 0 || arguments[0] === undefined ? '' : arguments[0]; 168 | var fn = arguments.length <= 1 || arguments[1] === undefined ? noop : arguments[1]; 169 | 170 | this.each(function (ele) { 171 | types.trim().split(/\s{1,}/).forEach(function (type) { 172 | ele.addEventListener(type, function (e) { 173 | var target = e.target || e.srcElement; 174 | if (fn.call(target, e) === false) { 175 | e.returnValue = true; 176 | e.cancelBubble = true; 177 | e.preventDefault && e.preventDefault(); 178 | e.stopPropagation && e.stopPropagation(); 179 | return false; 180 | } 181 | }, false); 182 | }); 183 | }); 184 | } 185 | }, { 186 | key: 'click', 187 | value: function click() { 188 | var fn = arguments.length <= 0 || arguments[0] === undefined ? noop : arguments[0]; 189 | 190 | this.bind('click', fn); 191 | return this; 192 | } 193 | }, { 194 | key: 'ready', 195 | value: function ready() { 196 | var _this2 = this; 197 | 198 | var fn = arguments.length <= 0 || arguments[0] === undefined ? noop : arguments[0]; 199 | 200 | window.addEventListener('DOMContentLoaded', function (e) { 201 | fn.call(_this2, e); 202 | }, false); 203 | } 204 | }, { 205 | key: 'observe', 206 | value: function observe() { 207 | var _this3 = this; 208 | 209 | var fn = arguments.length <= 0 || arguments[0] === undefined ? noop : arguments[0]; 210 | var config = arguments.length <= 1 || arguments[1] === undefined ? { childList: true, subtree: true } : arguments[1]; 211 | 212 | this.each(function (ele) { 213 | var MutationObserver = window.MutationObserver || window.WebKitMutationObserver || window.MozMutationObserver; 214 | var observer = new MutationObserver(function (mutations) { 215 | mutations.forEach(function (mutation) { 216 | fn.call(_this3, mutation.target, mutation.addedNodes, mutation.removedNodes); 217 | }); 218 | }); 219 | observer.observe(ele, config); 220 | }); 221 | return this; 222 | } 223 | }, { 224 | key: 'attr', 225 | value: function (_attr) { 226 | function attr(_x, _x2) { 227 | return _attr.apply(this, arguments); 228 | } 229 | 230 | attr.toString = function () { 231 | return _attr.toString(); 232 | }; 233 | 234 | return attr; 235 | }(function (attr, value) { 236 | // one agm 237 | if (arguments.length === 1) { 238 | // get attr value 239 | if (typeof attr === 'string') { 240 | return this[0].getAttribute(attr); 241 | } 242 | // set attr with a json 243 | else if ((typeof attr === 'undefined' ? 'undefined' : _typeof(attr)) === 'object') { 244 | this.each(function (ele) { 245 | for (var at in attr) { 246 | if (attr.hasOwnProperty(at)) { 247 | ele.setAttribute(at, value); 248 | } 249 | } 250 | }); 251 | return value; 252 | } 253 | } 254 | // set 255 | else if (arguments.length === 2) { 256 | this.each(function (ele) { 257 | ele.setAttribute(attr, value); 258 | }); 259 | return this; 260 | } else { 261 | return this; 262 | } 263 | }) 264 | }, { 265 | key: 'removeAttr', 266 | value: function removeAttr(attr) { 267 | if (arguments.length === 1) { 268 | this.each(function (ele) { 269 | ele.removeAttribute(attr); 270 | }); 271 | } 272 | return this; 273 | } 274 | }, { 275 | key: 'remove', 276 | value: function remove() { 277 | this.each(function (ele) { 278 | ele.remove(); 279 | }); 280 | this.length = 0; 281 | return this; 282 | } 283 | 284 | // get the element style 285 | 286 | }, { 287 | key: 'style', 288 | value: function style(attr) { 289 | return this[0].currentStyle ? this[0].currentStyle[attr] : getComputedStyle(this[0])[attr]; 290 | } 291 | 292 | // (attr,value) || 'string' || {} 293 | 294 | }, { 295 | key: 'css', 296 | value: function css() { 297 | for (var _len = arguments.length, agm = Array(_len), _key = 0; _key < _len; _key++) { 298 | agm[_key] = arguments[_key]; 299 | } 300 | 301 | if (agm.length === 1) { 302 | // get style 303 | if (typeof agm[0] === 'string') { 304 | // set style as a long text 305 | if (/:/ig.test(agm[0])) { 306 | this.each(function (ele) { 307 | ele.style.cssText = attr; 308 | }); 309 | } else { 310 | return this[0].currentStyle ? this[0].currentStyle[agm[0]] : getComputedStyle(this[0])[agm[0]]; 311 | } 312 | } 313 | // set style as a object 314 | else { 315 | this.each(function (ele) { 316 | for (var _attr2 in agm[0]) { 317 | if (agm[0].hasOwnProperty(_attr2)) { 318 | ele.style[_attr2] = agm[0][_attr2]; 319 | } 320 | } 321 | }); 322 | } 323 | } 324 | // set as (key,value) 325 | else if (agm.length === 2) { 326 | this.each(function (ele) { 327 | ele.style[agm[0]] = agm[1]; 328 | }); 329 | } 330 | return this; 331 | } 332 | }, { 333 | key: 'width', 334 | value: function width(value) { 335 | var element = this[0]; 336 | // window or document 337 | if (element.window === element || element.body) { 338 | return document.body.scrollWidth > document.documentElement.scrollWidth ? document.body.scrollWidth : document.documentElement.scrollWidth; 339 | } 340 | // set width 341 | else if (value) { 342 | this.each(function (ele) { 343 | ele.style.width = value + 'px'; 344 | }); 345 | return this; 346 | } 347 | // get width 348 | else { 349 | return this[0].offsetWidth || parseFloat(this.style('width')); 350 | } 351 | } 352 | }, { 353 | key: 'height', 354 | value: function height(value) { 355 | var ele = this[0]; 356 | // window or document 357 | if (ele.window === ele || ele.body) { 358 | return document.body.scrollHeight > document.documentElement.scrollHeight ? document.body.scrollHeight : document.documentElement.scrollHeight; 359 | } 360 | // set height 361 | else if (value) { 362 | this.each(function (ele) { 363 | ele.style.height = value + 'px'; 364 | }); 365 | return this; 366 | } 367 | // get height 368 | else { 369 | return this[0].offsetHeight || parseFloat(this.style('height')); 370 | } 371 | } 372 | }, { 373 | key: 'html', 374 | value: function html(value) { 375 | if (value !== undefined) { 376 | this.each(function (ele) { 377 | ele.innerHTML = typeof value === 'function' ? value(ele) : value; 378 | }); 379 | } else { 380 | return this[0].innerHTML; 381 | } 382 | return this; 383 | } 384 | }, { 385 | key: 'text', 386 | value: function text(value) { 387 | if (value === undefined) return this[0].innerText || this[0].textContent; 388 | 389 | this.each(function (ele) { 390 | ele.innerText = ele.textContent = value; 391 | }); 392 | return this; 393 | } 394 | }, { 395 | key: 'val', 396 | value: function val(value) { 397 | if (value === undefined) return this[0].value; 398 | this.each(function (ele) { 399 | ele.value = value; 400 | }); 401 | return this; 402 | } 403 | }, { 404 | key: 'show', 405 | value: function show() { 406 | this.each(function (ele) { 407 | ele.style.display = ''; 408 | }); 409 | return this; 410 | } 411 | }, { 412 | key: 'hide', 413 | value: function hide() { 414 | this.each(function (ele) { 415 | ele.style.display = 'none'; 416 | }); 417 | return this; 418 | } 419 | 420 | // content str || jqLite Object || DOM 421 | // here is jqLite Object 422 | 423 | }, { 424 | key: 'append', 425 | value: function append(content) { 426 | this.each(function (ele) { 427 | ele.appendChild(content[0]); 428 | }); 429 | return this; 430 | } 431 | }, { 432 | key: 'prepend', 433 | 434 | 435 | // content str || jqLite Object || DOM 436 | // here is jqLite Object 437 | value: function prepend(content) { 438 | this.each(function (ele) { 439 | ele.insertBefore(content[0], ele.children[0]); 440 | }); 441 | return this; 442 | } 443 | }, { 444 | key: 'hasClass', 445 | value: function hasClass(className) { 446 | if (!this[0]) return false; 447 | return this[0].classList.contains(className); 448 | } 449 | }, { 450 | key: 'addClass', 451 | value: function addClass(className) { 452 | this.each(function (ele) { 453 | ele.classList.add(className); 454 | }); 455 | return this; 456 | } 457 | }, { 458 | key: 'removeClass', 459 | value: function removeClass(className) { 460 | this.each(function (ele) { 461 | ele.classList.remove(className); 462 | }); 463 | return this; 464 | } 465 | }, { 466 | key: 'index', 467 | get: function get() { 468 | var index = 0; 469 | var brothers = this[0].parentNode.children; 470 | for (var i = 0; i < brothers.length; i++) { 471 | if (brothers[i] == this[0]) { 472 | index = i; 473 | break; 474 | } 475 | } 476 | return index; 477 | } 478 | }], [{ 479 | key: 'fn', 480 | get: function get() { 481 | var visible = function visible(ele) { 482 | var pos = ele.getBoundingClientRect(); 483 | var w = void 0; 484 | var h = void 0; 485 | var inViewPort = void 0; 486 | var docEle = document.documentElement; 487 | var docBody = document.body; 488 | if (docEle.getBoundingClientRect) { 489 | w = docEle.clientWidth || docBody.clientWidth; 490 | h = docEle.clientHeight || docBody.clientHeight; 491 | inViewPort = pos.top > h || pos.bottom < 0 || pos.left > w || pos.right < 0; 492 | return inViewPort ? false : true; 493 | } 494 | }; 495 | var merge = function merge() { 496 | for (var _len2 = arguments.length, sources = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { 497 | sources[_key2] = arguments[_key2]; 498 | } 499 | 500 | return Object.assign.apply(Object, [{}].concat(sources)); 501 | }; 502 | return { 503 | visible: visible, 504 | merge: merge 505 | }; 506 | } 507 | }]); 508 | 509 | return jqLite; 510 | }(); 511 | 512 | var $ = function $() { 513 | var selectors = arguments.length <= 0 || arguments[0] === undefined ? '' : arguments[0]; 514 | var context = arguments.length <= 1 || arguments[1] === undefined ? document : arguments[1]; 515 | 516 | return new jqLite(selectors, context); 517 | }; 518 | $.fn = jqLite.fn; 519 | 520 | exports.default = $; 521 | 522 | /***/ }, 523 | /* 2 */ 524 | /***/ function(module, exports, __webpack_require__) { 525 | 526 | 'use strict'; 527 | var ctx = __webpack_require__(3) 528 | , $export = __webpack_require__(5) 529 | , toObject = __webpack_require__(15) 530 | , call = __webpack_require__(17) 531 | , isArrayIter = __webpack_require__(20) 532 | , toLength = __webpack_require__(24) 533 | , getIterFn = __webpack_require__(26); 534 | $export($export.S + $export.F * !__webpack_require__(29)(function(iter){ Array.from(iter); }), 'Array', { 535 | // 22.1.2.1 Array.from(arrayLike, mapfn = undefined, thisArg = undefined) 536 | from: function from(arrayLike/*, mapfn = undefined, thisArg = undefined*/){ 537 | var O = toObject(arrayLike) 538 | , C = typeof this == 'function' ? this : Array 539 | , $$ = arguments 540 | , $$len = $$.length 541 | , mapfn = $$len > 1 ? $$[1] : undefined 542 | , mapping = mapfn !== undefined 543 | , index = 0 544 | , iterFn = getIterFn(O) 545 | , length, result, step, iterator; 546 | if(mapping)mapfn = ctx(mapfn, $$len > 2 ? $$[2] : undefined, 2); 547 | // if object isn't iterable or it's array with default iterator - use simple case 548 | if(iterFn != undefined && !(C == Array && isArrayIter(iterFn))){ 549 | for(iterator = iterFn.call(O), result = new C; !(step = iterator.next()).done; index++){ 550 | result[index] = mapping ? call(iterator, mapfn, [step.value, index], true) : step.value; 551 | } 552 | } else { 553 | length = toLength(O.length); 554 | for(result = new C(length); length > index; index++){ 555 | result[index] = mapping ? mapfn(O[index], index) : O[index]; 556 | } 557 | } 558 | result.length = index; 559 | return result; 560 | } 561 | }); 562 | 563 | 564 | /***/ }, 565 | /* 3 */ 566 | /***/ function(module, exports, __webpack_require__) { 567 | 568 | // optional / simple context binding 569 | var aFunction = __webpack_require__(4); 570 | module.exports = function(fn, that, length){ 571 | aFunction(fn); 572 | if(that === undefined)return fn; 573 | switch(length){ 574 | case 1: return function(a){ 575 | return fn.call(that, a); 576 | }; 577 | case 2: return function(a, b){ 578 | return fn.call(that, a, b); 579 | }; 580 | case 3: return function(a, b, c){ 581 | return fn.call(that, a, b, c); 582 | }; 583 | } 584 | return function(/* ...args */){ 585 | return fn.apply(that, arguments); 586 | }; 587 | }; 588 | 589 | /***/ }, 590 | /* 4 */ 591 | /***/ function(module, exports) { 592 | 593 | module.exports = function(it){ 594 | if(typeof it != 'function')throw TypeError(it + ' is not a function!'); 595 | return it; 596 | }; 597 | 598 | /***/ }, 599 | /* 5 */ 600 | /***/ function(module, exports, __webpack_require__) { 601 | 602 | var global = __webpack_require__(6) 603 | , core = __webpack_require__(7) 604 | , hide = __webpack_require__(8) 605 | , redefine = __webpack_require__(13) 606 | , ctx = __webpack_require__(3) 607 | , PROTOTYPE = 'prototype'; 608 | 609 | var $export = function(type, name, source){ 610 | var IS_FORCED = type & $export.F 611 | , IS_GLOBAL = type & $export.G 612 | , IS_STATIC = type & $export.S 613 | , IS_PROTO = type & $export.P 614 | , IS_BIND = type & $export.B 615 | , target = IS_GLOBAL ? global : IS_STATIC ? global[name] || (global[name] = {}) : (global[name] || {})[PROTOTYPE] 616 | , exports = IS_GLOBAL ? core : core[name] || (core[name] = {}) 617 | , expProto = exports[PROTOTYPE] || (exports[PROTOTYPE] = {}) 618 | , key, own, out, exp; 619 | if(IS_GLOBAL)source = name; 620 | for(key in source){ 621 | // contains in native 622 | own = !IS_FORCED && target && key in target; 623 | // export native or passed 624 | out = (own ? target : source)[key]; 625 | // bind timers to global for call from export context 626 | exp = IS_BIND && own ? ctx(out, global) : IS_PROTO && typeof out == 'function' ? ctx(Function.call, out) : out; 627 | // extend global 628 | if(target && !own)redefine(target, key, out); 629 | // export 630 | if(exports[key] != out)hide(exports, key, exp); 631 | if(IS_PROTO && expProto[key] != out)expProto[key] = out; 632 | } 633 | }; 634 | global.core = core; 635 | // type bitmap 636 | $export.F = 1; // forced 637 | $export.G = 2; // global 638 | $export.S = 4; // static 639 | $export.P = 8; // proto 640 | $export.B = 16; // bind 641 | $export.W = 32; // wrap 642 | module.exports = $export; 643 | 644 | /***/ }, 645 | /* 6 */ 646 | /***/ function(module, exports) { 647 | 648 | // https://github.com/zloirock/core-js/issues/86#issuecomment-115759028 649 | var global = module.exports = typeof window != 'undefined' && window.Math == Math 650 | ? window : typeof self != 'undefined' && self.Math == Math ? self : Function('return this')(); 651 | if(typeof __g == 'number')__g = global; // eslint-disable-line no-undef 652 | 653 | /***/ }, 654 | /* 7 */ 655 | /***/ function(module, exports) { 656 | 657 | var core = module.exports = {version: '1.2.6'}; 658 | if(typeof __e == 'number')__e = core; // eslint-disable-line no-undef 659 | 660 | /***/ }, 661 | /* 8 */ 662 | /***/ function(module, exports, __webpack_require__) { 663 | 664 | var $ = __webpack_require__(9) 665 | , createDesc = __webpack_require__(10); 666 | module.exports = __webpack_require__(11) ? function(object, key, value){ 667 | return $.setDesc(object, key, createDesc(1, value)); 668 | } : function(object, key, value){ 669 | object[key] = value; 670 | return object; 671 | }; 672 | 673 | /***/ }, 674 | /* 9 */ 675 | /***/ function(module, exports) { 676 | 677 | var $Object = Object; 678 | module.exports = { 679 | create: $Object.create, 680 | getProto: $Object.getPrototypeOf, 681 | isEnum: {}.propertyIsEnumerable, 682 | getDesc: $Object.getOwnPropertyDescriptor, 683 | setDesc: $Object.defineProperty, 684 | setDescs: $Object.defineProperties, 685 | getKeys: $Object.keys, 686 | getNames: $Object.getOwnPropertyNames, 687 | getSymbols: $Object.getOwnPropertySymbols, 688 | each: [].forEach 689 | }; 690 | 691 | /***/ }, 692 | /* 10 */ 693 | /***/ function(module, exports) { 694 | 695 | module.exports = function(bitmap, value){ 696 | return { 697 | enumerable : !(bitmap & 1), 698 | configurable: !(bitmap & 2), 699 | writable : !(bitmap & 4), 700 | value : value 701 | }; 702 | }; 703 | 704 | /***/ }, 705 | /* 11 */ 706 | /***/ function(module, exports, __webpack_require__) { 707 | 708 | // Thank's IE8 for his funny defineProperty 709 | module.exports = !__webpack_require__(12)(function(){ 710 | return Object.defineProperty({}, 'a', {get: function(){ return 7; }}).a != 7; 711 | }); 712 | 713 | /***/ }, 714 | /* 12 */ 715 | /***/ function(module, exports) { 716 | 717 | module.exports = function(exec){ 718 | try { 719 | return !!exec(); 720 | } catch(e){ 721 | return true; 722 | } 723 | }; 724 | 725 | /***/ }, 726 | /* 13 */ 727 | /***/ function(module, exports, __webpack_require__) { 728 | 729 | // add fake Function#toString 730 | // for correct work wrapped methods / constructors with methods like LoDash isNative 731 | var global = __webpack_require__(6) 732 | , hide = __webpack_require__(8) 733 | , SRC = __webpack_require__(14)('src') 734 | , TO_STRING = 'toString' 735 | , $toString = Function[TO_STRING] 736 | , TPL = ('' + $toString).split(TO_STRING); 737 | 738 | __webpack_require__(7).inspectSource = function(it){ 739 | return $toString.call(it); 740 | }; 741 | 742 | (module.exports = function(O, key, val, safe){ 743 | if(typeof val == 'function'){ 744 | val.hasOwnProperty(SRC) || hide(val, SRC, O[key] ? '' + O[key] : TPL.join(String(key))); 745 | val.hasOwnProperty('name') || hide(val, 'name', key); 746 | } 747 | if(O === global){ 748 | O[key] = val; 749 | } else { 750 | if(!safe)delete O[key]; 751 | hide(O, key, val); 752 | } 753 | })(Function.prototype, TO_STRING, function toString(){ 754 | return typeof this == 'function' && this[SRC] || $toString.call(this); 755 | }); 756 | 757 | /***/ }, 758 | /* 14 */ 759 | /***/ function(module, exports) { 760 | 761 | var id = 0 762 | , px = Math.random(); 763 | module.exports = function(key){ 764 | return 'Symbol('.concat(key === undefined ? '' : key, ')_', (++id + px).toString(36)); 765 | }; 766 | 767 | /***/ }, 768 | /* 15 */ 769 | /***/ function(module, exports, __webpack_require__) { 770 | 771 | // 7.1.13 ToObject(argument) 772 | var defined = __webpack_require__(16); 773 | module.exports = function(it){ 774 | return Object(defined(it)); 775 | }; 776 | 777 | /***/ }, 778 | /* 16 */ 779 | /***/ function(module, exports) { 780 | 781 | // 7.2.1 RequireObjectCoercible(argument) 782 | module.exports = function(it){ 783 | if(it == undefined)throw TypeError("Can't call method on " + it); 784 | return it; 785 | }; 786 | 787 | /***/ }, 788 | /* 17 */ 789 | /***/ function(module, exports, __webpack_require__) { 790 | 791 | // call something on iterator step with safe closing on error 792 | var anObject = __webpack_require__(18); 793 | module.exports = function(iterator, fn, value, entries){ 794 | try { 795 | return entries ? fn(anObject(value)[0], value[1]) : fn(value); 796 | // 7.4.6 IteratorClose(iterator, completion) 797 | } catch(e){ 798 | var ret = iterator['return']; 799 | if(ret !== undefined)anObject(ret.call(iterator)); 800 | throw e; 801 | } 802 | }; 803 | 804 | /***/ }, 805 | /* 18 */ 806 | /***/ function(module, exports, __webpack_require__) { 807 | 808 | var isObject = __webpack_require__(19); 809 | module.exports = function(it){ 810 | if(!isObject(it))throw TypeError(it + ' is not an object!'); 811 | return it; 812 | }; 813 | 814 | /***/ }, 815 | /* 19 */ 816 | /***/ function(module, exports) { 817 | 818 | module.exports = function(it){ 819 | return typeof it === 'object' ? it !== null : typeof it === 'function'; 820 | }; 821 | 822 | /***/ }, 823 | /* 20 */ 824 | /***/ function(module, exports, __webpack_require__) { 825 | 826 | // check on default Array iterator 827 | var Iterators = __webpack_require__(21) 828 | , ITERATOR = __webpack_require__(22)('iterator') 829 | , ArrayProto = Array.prototype; 830 | 831 | module.exports = function(it){ 832 | return it !== undefined && (Iterators.Array === it || ArrayProto[ITERATOR] === it); 833 | }; 834 | 835 | /***/ }, 836 | /* 21 */ 837 | /***/ function(module, exports) { 838 | 839 | module.exports = {}; 840 | 841 | /***/ }, 842 | /* 22 */ 843 | /***/ function(module, exports, __webpack_require__) { 844 | 845 | var store = __webpack_require__(23)('wks') 846 | , uid = __webpack_require__(14) 847 | , Symbol = __webpack_require__(6).Symbol; 848 | module.exports = function(name){ 849 | return store[name] || (store[name] = 850 | Symbol && Symbol[name] || (Symbol || uid)('Symbol.' + name)); 851 | }; 852 | 853 | /***/ }, 854 | /* 23 */ 855 | /***/ function(module, exports, __webpack_require__) { 856 | 857 | var global = __webpack_require__(6) 858 | , SHARED = '__core-js_shared__' 859 | , store = global[SHARED] || (global[SHARED] = {}); 860 | module.exports = function(key){ 861 | return store[key] || (store[key] = {}); 862 | }; 863 | 864 | /***/ }, 865 | /* 24 */ 866 | /***/ function(module, exports, __webpack_require__) { 867 | 868 | // 7.1.15 ToLength 869 | var toInteger = __webpack_require__(25) 870 | , min = Math.min; 871 | module.exports = function(it){ 872 | return it > 0 ? min(toInteger(it), 0x1fffffffffffff) : 0; // pow(2, 53) - 1 == 9007199254740991 873 | }; 874 | 875 | /***/ }, 876 | /* 25 */ 877 | /***/ function(module, exports) { 878 | 879 | // 7.1.4 ToInteger 880 | var ceil = Math.ceil 881 | , floor = Math.floor; 882 | module.exports = function(it){ 883 | return isNaN(it = +it) ? 0 : (it > 0 ? floor : ceil)(it); 884 | }; 885 | 886 | /***/ }, 887 | /* 26 */ 888 | /***/ function(module, exports, __webpack_require__) { 889 | 890 | var classof = __webpack_require__(27) 891 | , ITERATOR = __webpack_require__(22)('iterator') 892 | , Iterators = __webpack_require__(21); 893 | module.exports = __webpack_require__(7).getIteratorMethod = function(it){ 894 | if(it != undefined)return it[ITERATOR] 895 | || it['@@iterator'] 896 | || Iterators[classof(it)]; 897 | }; 898 | 899 | /***/ }, 900 | /* 27 */ 901 | /***/ function(module, exports, __webpack_require__) { 902 | 903 | // getting tag from 19.1.3.6 Object.prototype.toString() 904 | var cof = __webpack_require__(28) 905 | , TAG = __webpack_require__(22)('toStringTag') 906 | // ES3 wrong here 907 | , ARG = cof(function(){ return arguments; }()) == 'Arguments'; 908 | 909 | module.exports = function(it){ 910 | var O, T, B; 911 | return it === undefined ? 'Undefined' : it === null ? 'Null' 912 | // @@toStringTag case 913 | : typeof (T = (O = Object(it))[TAG]) == 'string' ? T 914 | // builtinTag case 915 | : ARG ? cof(O) 916 | // ES3 arguments fallback 917 | : (B = cof(O)) == 'Object' && typeof O.callee == 'function' ? 'Arguments' : B; 918 | }; 919 | 920 | /***/ }, 921 | /* 28 */ 922 | /***/ function(module, exports) { 923 | 924 | var toString = {}.toString; 925 | 926 | module.exports = function(it){ 927 | return toString.call(it).slice(8, -1); 928 | }; 929 | 930 | /***/ }, 931 | /* 29 */ 932 | /***/ function(module, exports, __webpack_require__) { 933 | 934 | var ITERATOR = __webpack_require__(22)('iterator') 935 | , SAFE_CLOSING = false; 936 | 937 | try { 938 | var riter = [7][ITERATOR](); 939 | riter['return'] = function(){ SAFE_CLOSING = true; }; 940 | Array.from(riter, function(){ throw 2; }); 941 | } catch(e){ /* empty */ } 942 | 943 | module.exports = function(exec, skipClosing){ 944 | if(!skipClosing && !SAFE_CLOSING)return false; 945 | var safe = false; 946 | try { 947 | var arr = [7] 948 | , iter = arr[ITERATOR](); 949 | iter.next = function(){ safe = true; }; 950 | arr[ITERATOR] = function(){ return iter; }; 951 | exec(arr); 952 | } catch(e){ /* empty */ } 953 | return safe; 954 | }; 955 | 956 | /***/ }, 957 | /* 30 */ 958 | /***/ function(module, exports, __webpack_require__) { 959 | 960 | // 19.1.3.1 Object.assign(target, source) 961 | var $export = __webpack_require__(5); 962 | 963 | $export($export.S + $export.F, 'Object', {assign: __webpack_require__(31)}); 964 | 965 | /***/ }, 966 | /* 31 */ 967 | /***/ function(module, exports, __webpack_require__) { 968 | 969 | // 19.1.2.1 Object.assign(target, source, ...) 970 | var $ = __webpack_require__(9) 971 | , toObject = __webpack_require__(15) 972 | , IObject = __webpack_require__(32); 973 | 974 | // should work with symbols and should have deterministic property order (V8 bug) 975 | module.exports = __webpack_require__(12)(function(){ 976 | var a = Object.assign 977 | , A = {} 978 | , B = {} 979 | , S = Symbol() 980 | , K = 'abcdefghijklmnopqrst'; 981 | A[S] = 7; 982 | K.split('').forEach(function(k){ B[k] = k; }); 983 | return a({}, A)[S] != 7 || Object.keys(a({}, B)).join('') != K; 984 | }) ? function assign(target, source){ // eslint-disable-line no-unused-vars 985 | var T = toObject(target) 986 | , $$ = arguments 987 | , $$len = $$.length 988 | , index = 1 989 | , getKeys = $.getKeys 990 | , getSymbols = $.getSymbols 991 | , isEnum = $.isEnum; 992 | while($$len > index){ 993 | var S = IObject($$[index++]) 994 | , keys = getSymbols ? getKeys(S).concat(getSymbols(S)) : getKeys(S) 995 | , length = keys.length 996 | , j = 0 997 | , key; 998 | while(length > j)if(isEnum.call(S, key = keys[j++]))T[key] = S[key]; 999 | } 1000 | return T; 1001 | } : Object.assign; 1002 | 1003 | /***/ }, 1004 | /* 32 */ 1005 | /***/ function(module, exports, __webpack_require__) { 1006 | 1007 | // fallback for non-array-like ES3 and non-enumerable old V8 strings 1008 | var cof = __webpack_require__(28); 1009 | module.exports = Object('z').propertyIsEnumerable(0) ? Object : function(it){ 1010 | return cof(it) == 'String' ? it.split('') : Object(it); 1011 | }; 1012 | 1013 | /***/ }, 1014 | /* 33 */, 1015 | /* 34 */, 1016 | /* 35 */, 1017 | /* 36 */, 1018 | /* 37 */, 1019 | /* 38 */, 1020 | /* 39 */, 1021 | /* 40 */, 1022 | /* 41 */, 1023 | /* 42 */, 1024 | /* 43 */, 1025 | /* 44 */, 1026 | /* 45 */, 1027 | /* 46 */, 1028 | /* 47 */, 1029 | /* 48 */, 1030 | /* 49 */, 1031 | /* 50 */, 1032 | /* 51 */ 1033 | /***/ function(module, exports) { 1034 | 1035 | "use strict"; 1036 | 1037 | Object.defineProperty(exports, "__esModule", { 1038 | value: true 1039 | }); 1040 | /* 1041 | * 频率控制 返回函数连续调用时,fn 执行频率限定为每多少时间执行一次 1042 | * @param fn {function} 需要调用的函数 1043 | * @param delay {number} 延迟时间,单位毫秒 1044 | * @param immediate {bool} 给 immediate参数传递false 绑定的函数先执行,而不是delay后后执行。 1045 | * @return {function}实际调用函数 1046 | */ 1047 | var $throttle = function $throttle(fn, delay, immediate, debounce) { 1048 | var curr = +new Date(), 1049 | //当前事件 1050 | last_call = 0, 1051 | last_exec = 0, 1052 | timer = null, 1053 | diff, 1054 | //时间差 1055 | context, 1056 | //上下文 1057 | args, 1058 | exec = function exec() { 1059 | last_exec = curr; 1060 | fn.apply(context, args); 1061 | }; 1062 | return function () { 1063 | curr = +new Date(); 1064 | context = this, args = arguments, diff = curr - (debounce ? last_call : last_exec) - delay; 1065 | clearTimeout(timer); 1066 | if (debounce) { 1067 | if (immediate) { 1068 | timer = setTimeout(exec, delay); 1069 | } else if (diff >= 0) { 1070 | exec(); 1071 | } 1072 | } else { 1073 | if (diff >= 0) { 1074 | exec(); 1075 | } else if (immediate) { 1076 | timer = setTimeout(exec, -diff); 1077 | } 1078 | } 1079 | last_call = curr; 1080 | }; 1081 | }; 1082 | 1083 | /* 1084 | * 空闲控制 返回函数连续调用时,空闲时间必须大于或等于 delay,fn 才会执行 1085 | * @param fn {function} 要调用的函数 1086 | * @param delay {number} 空闲时间 1087 | * @param immediate {bool} 给 immediate参数传递false 绑定的函数先执行,而不是delay后后执行。 1088 | * @return {function}实际调用函数 1089 | */ 1090 | 1091 | var $debounce = function $debounce(fn, delay, immediate) { 1092 | return $throttle(fn, delay, immediate, true); 1093 | }; 1094 | 1095 | exports.$debounce = $debounce; 1096 | exports.$throttle = $throttle; 1097 | 1098 | /***/ }, 1099 | /* 52 */, 1100 | /* 53 */, 1101 | /* 54 */, 1102 | /* 55 */ 1103 | /***/ function(module, exports) { 1104 | 1105 | "use strict"; 1106 | 1107 | Object.defineProperty(exports, "__esModule", { 1108 | value: true 1109 | }); 1110 | var $interval = function $interval(fn, delay) { 1111 | var interval = function interval() { 1112 | fn.call(undefined); 1113 | id = setTimeout(interval, delay); 1114 | }; 1115 | 1116 | var id = setTimeout(interval, delay); 1117 | 1118 | return function () { 1119 | window.clearTimeout(id); 1120 | }; 1121 | }; 1122 | 1123 | $interval.cancel = function (timerFunc) { 1124 | timerFunc(); 1125 | }; 1126 | 1127 | exports.default = $interval; 1128 | 1129 | /***/ }, 1130 | /* 56 */, 1131 | /* 57 */, 1132 | /* 58 */ 1133 | /***/ function(module, exports, __webpack_require__) { 1134 | 1135 | 'use strict'; 1136 | 1137 | var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); 1138 | 1139 | var _jqLite = __webpack_require__(1); 1140 | 1141 | var _jqLite2 = _interopRequireDefault(_jqLite); 1142 | 1143 | var _config = __webpack_require__(59); 1144 | 1145 | var _config2 = _interopRequireDefault(_config); 1146 | 1147 | var _$interval = __webpack_require__(55); 1148 | 1149 | var _$interval2 = _interopRequireDefault(_$interval); 1150 | 1151 | var _$debounce = __webpack_require__(51); 1152 | 1153 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 1154 | 1155 | function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } 1156 | 1157 | var main = function () { 1158 | function main() { 1159 | var agm = arguments.length <= 0 || arguments[0] === undefined ? '' : arguments[0]; 1160 | 1161 | _classCallCheck(this, main); 1162 | 1163 | if (!agm) return this; 1164 | 1165 | this.ads = (0, _jqLite2.default)(agm); 1166 | } 1167 | 1168 | _createClass(main, [{ 1169 | key: 'filter', 1170 | value: function filter() { 1171 | this.ads.each(function (ele) { 1172 | if (ele.$$filtered) return; 1173 | ele.style.cssText = _config2.default.debug ? '\n border:2px solid red;\n ' : '\n display:none !important;\n visibility:hidden !important;\n width:0 !important;\n height:0 !important;\n overflow:hidden !important;\n '; 1174 | ele.$$filtered = true; 1175 | }); 1176 | return this; 1177 | } 1178 | }, { 1179 | key: 'keyword', 1180 | value: function keyword() { 1181 | (0, _jqLite2.default)(_config2.default.keyRules).each(function (aEle) { 1182 | if (aEle.$$filtered) return; 1183 | aEle.removeAttribute('data-swapword'); 1184 | aEle.removeAttribute('class'); 1185 | aEle.removeAttribute('href'); 1186 | aEle.style.cssText = _config2.default.debug ? '\n color:#fff !important;\n background-color:red !important;\n ' : '\n color:inherit !important;\n '; 1187 | aEle.$$filtered = true; 1188 | }); 1189 | return this; 1190 | } 1191 | }]); 1192 | 1193 | return main; 1194 | }(); 1195 | 1196 | var loop = (0, _$interval2.default)(function () { 1197 | new main(_config2.default.adRules).filter().keyword(); 1198 | }, 50); 1199 | 1200 | console.info('贴吧去广告启动...'); 1201 | 1202 | (0, _jqLite2.default)(document).bind('DOMContentLoaded', function () { 1203 | 1204 | _$interval2.default.cancel(loop); 1205 | 1206 | // init 1207 | new main(_config2.default.adRules).filter().keyword(); 1208 | 1209 | (0, _jqLite2.default)(document).observe((0, _$debounce.$debounce)(function (target, addList, removeList) { 1210 | if (!addList || !addList.length) return; 1211 | new main(_config2.default.adRules).filter().keyword(); 1212 | }, 200)); 1213 | 1214 | (0, _jqLite2.default)(window).bind('scroll', (0, _$debounce.$debounce)(function () { 1215 | new main(_config2.default.adRules).filter().keyword(); 1216 | }, 200)); 1217 | }); 1218 | 1219 | /***/ }, 1220 | /* 59 */ 1221 | /***/ function(module, exports) { 1222 | 1223 | 'use strict'; 1224 | 1225 | Object.defineProperty(exports, "__esModule", { 1226 | value: true 1227 | }); 1228 | var CONFIG = { 1229 | // 是否是调试模式 1230 | debug: false, 1231 | adRules: '\n ul#thread_list *[data-daid],\n ul#thread_list>li:not([data-field]):not(.thread_top_list_folder)\n ,\n #j_p_postlist *[data-daid],\n #j_p_postlist *[data-isautoreply]\n ,\n #thread_list>li\n :not([class*="list"])\n :not([data-field])\n ,\n .p_postlist>div\n :not(.p_postlist)\n :not([class*="post"])\n :not([data-field])\n ,\n #aside *[data-daid],\n #aside>div[class*="clearfix"],\n #aside DIV[id$="ad"],\n #aside #encourage_entry,\n .my_app,.j_encourage_entry,\n .right_section>div.u9_aside,\n .right_section>div.clearfix,\n .right_section *[data-daid]\n ,\n #pb_adbanner,#pb_adbanner *[data-daid]\n ,\n #com_u9_head,\n .u9_head,\n div.search_form>div[class*="clearfix"]\n ,\n .firework-wrap\n '.trim().replace(/\n/img, '').replace(/\s{1,}([^a-z\*])/ig, '$1'), 1232 | keyRules: '\n #j_p_postlist a[data-swapword]:not([filted]),\n #j_p_postlist a.ps_cb:not([filted])\n '.trim().replace(/\n/img, '').replace(/\s{1,}([^a-z\*])/ig, '$1') 1233 | }; 1234 | 1235 | exports.default = CONFIG; 1236 | 1237 | /***/ } 1238 | /******/ ]); -------------------------------------------------------------------------------- /dist/remove_zhihu_redirect.user.js: -------------------------------------------------------------------------------- 1 | // ==UserScript== 2 | // @name 去除知乎跳转 3 | // @author axetroy 4 | // @description 去除知乎重定向,不再跳转 5 | // @version 2016.6.6.1 6 | // @include *www.zhihu.com* 7 | // @include *zhuanlan.zhihu.com* 8 | // @connect tags 9 | // @connect * 10 | // @compatible chrome 完美运行 11 | // @compatible firefox 完美运行 12 | // @supportURL http://www.burningall.com 13 | // @run-at document-start 14 | // @contributionURL troy450409405@gmail.com|alipay.com 15 | // @namespace https://greasyfork.org/zh-CN/users/3400-axetroy 16 | // @license The MIT License (MIT); http://opensource.org/licenses/MIT 17 | // ==/UserScript== 18 | 19 | /* 20 | 21 | Github源码:https://github.com/axetroy/GMscript 22 | 23 | */ 24 | /******/ (function(modules) { // webpackBootstrap 25 | /******/ // The module cache 26 | /******/ var installedModules = {}; 27 | 28 | /******/ // The require function 29 | /******/ function __webpack_require__(moduleId) { 30 | 31 | /******/ // Check if module is in cache 32 | /******/ if(installedModules[moduleId]) 33 | /******/ return installedModules[moduleId].exports; 34 | 35 | /******/ // Create a new module (and put it into the cache) 36 | /******/ var module = installedModules[moduleId] = { 37 | /******/ exports: {}, 38 | /******/ id: moduleId, 39 | /******/ loaded: false 40 | /******/ }; 41 | 42 | /******/ // Execute the module function 43 | /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); 44 | 45 | /******/ // Flag the module as loaded 46 | /******/ module.loaded = true; 47 | 48 | /******/ // Return the exports of the module 49 | /******/ return module.exports; 50 | /******/ } 51 | 52 | 53 | /******/ // expose the modules object (__webpack_modules__) 54 | /******/ __webpack_require__.m = modules; 55 | 56 | /******/ // expose the module cache 57 | /******/ __webpack_require__.c = installedModules; 58 | 59 | /******/ // __webpack_public_path__ 60 | /******/ __webpack_require__.p = ""; 61 | 62 | /******/ // Load entry module and return exports 63 | /******/ return __webpack_require__(0); 64 | /******/ }) 65 | /************************************************************************/ 66 | /******/ ([ 67 | /* 0 */ 68 | /***/ function(module, exports, __webpack_require__) { 69 | 70 | 'use strict'; 71 | 72 | var _jqLite = __webpack_require__(1); 73 | 74 | var _jqLite2 = _interopRequireDefault(_jqLite); 75 | 76 | var _$debounce = __webpack_require__(51); 77 | 78 | var _main = __webpack_require__(60); 79 | 80 | var _main2 = _interopRequireDefault(_main); 81 | 82 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 83 | 84 | var redirect = 'link.zhihu.com/?target='; /** 85 | * Created by axetroy on 16-6-4. 86 | */ 87 | 88 | var config = { 89 | rules: ('\n a[href*="' + redirect + '"]\n ').trim().replace(/\n/img, '').replace(/\s{1,}([^a-zA-Z])/g, '$1') 90 | }; 91 | 92 | (0, _jqLite2.default)(function () { 93 | // init 94 | new _main2.default(config.rules).redirect(); 95 | 96 | (0, _jqLite2.default)(document).observe((0, _$debounce.$debounce)(function (target, addList, removeList) { 97 | if (!addList || !addList.length) return; 98 | new _main2.default(config.rules).redirect(); 99 | }, 200)); 100 | 101 | (0, _jqLite2.default)(window).bind('scroll', (0, _$debounce.$debounce)(function () { 102 | new _main2.default(config.rules).redirect(); 103 | }, 200)); 104 | }); 105 | 106 | /***/ }, 107 | /* 1 */ 108 | /***/ function(module, exports, __webpack_require__) { 109 | 110 | 'use strict'; 111 | 112 | // es6 Array.from 113 | 114 | Object.defineProperty(exports, "__esModule", { 115 | value: true 116 | }); 117 | 118 | var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol ? "symbol" : typeof obj; }; 119 | 120 | var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); 121 | // es6 Object.assign 122 | 123 | 124 | __webpack_require__(2); 125 | 126 | __webpack_require__(30); 127 | 128 | function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } 129 | 130 | var noop = function noop(x) { 131 | return x; 132 | }; 133 | 134 | var jqLite = function () { 135 | function jqLite() { 136 | var _this = this; 137 | 138 | var selectors = arguments.length <= 0 || arguments[0] === undefined ? '' : arguments[0]; 139 | var context = arguments.length <= 1 || arguments[1] === undefined ? document : arguments[1]; 140 | 141 | _classCallCheck(this, jqLite); 142 | 143 | this.selectors = selectors; 144 | this.context = context; 145 | this.length = 0; 146 | 147 | switch (typeof selectors === 'undefined' ? 'undefined' : _typeof(selectors)) { 148 | case 'undefined': 149 | break; 150 | case 'string': 151 | Array.from(context.querySelectorAll(selectors), function (ele, i) { 152 | _this[i] = ele; 153 | _this.length++; 154 | }, this); 155 | break; 156 | case 'object': 157 | if (selectors.length) { 158 | Array.from(selectors, function (ele, i) { 159 | _this[i] = ele; 160 | _this.length++; 161 | }, this); 162 | } else { 163 | this[0] = selectors; 164 | this.length = 1; 165 | } 166 | break; 167 | case 'function': 168 | this.ready(selectors); 169 | break; 170 | default: 171 | 172 | } 173 | } 174 | 175 | _createClass(jqLite, [{ 176 | key: 'eq', 177 | value: function eq() { 178 | var n = arguments.length <= 0 || arguments[0] === undefined ? 0 : arguments[0]; 179 | 180 | return new jqLite(this[n]); 181 | } 182 | }, { 183 | key: 'find', 184 | value: function find(selectors) { 185 | return new jqLite(selectors, this[0]); 186 | } 187 | }, { 188 | key: 'each', 189 | value: function each() { 190 | var fn = arguments.length <= 0 || arguments[0] === undefined ? noop : arguments[0]; 191 | 192 | for (var i = 0; i < this.length; i++) { 193 | fn.call(this, this[i], i); 194 | } 195 | return this; 196 | } 197 | }, { 198 | key: 'bind', 199 | value: function bind() { 200 | var types = arguments.length <= 0 || arguments[0] === undefined ? '' : arguments[0]; 201 | var fn = arguments.length <= 1 || arguments[1] === undefined ? noop : arguments[1]; 202 | 203 | this.each(function (ele) { 204 | types.trim().split(/\s{1,}/).forEach(function (type) { 205 | ele.addEventListener(type, function (e) { 206 | var target = e.target || e.srcElement; 207 | if (fn.call(target, e) === false) { 208 | e.returnValue = true; 209 | e.cancelBubble = true; 210 | e.preventDefault && e.preventDefault(); 211 | e.stopPropagation && e.stopPropagation(); 212 | return false; 213 | } 214 | }, false); 215 | }); 216 | }); 217 | } 218 | }, { 219 | key: 'click', 220 | value: function click() { 221 | var fn = arguments.length <= 0 || arguments[0] === undefined ? noop : arguments[0]; 222 | 223 | this.bind('click', fn); 224 | return this; 225 | } 226 | }, { 227 | key: 'ready', 228 | value: function ready() { 229 | var _this2 = this; 230 | 231 | var fn = arguments.length <= 0 || arguments[0] === undefined ? noop : arguments[0]; 232 | 233 | window.addEventListener('DOMContentLoaded', function (e) { 234 | fn.call(_this2, e); 235 | }, false); 236 | } 237 | }, { 238 | key: 'observe', 239 | value: function observe() { 240 | var _this3 = this; 241 | 242 | var fn = arguments.length <= 0 || arguments[0] === undefined ? noop : arguments[0]; 243 | var config = arguments.length <= 1 || arguments[1] === undefined ? { childList: true, subtree: true } : arguments[1]; 244 | 245 | this.each(function (ele) { 246 | var MutationObserver = window.MutationObserver || window.WebKitMutationObserver || window.MozMutationObserver; 247 | var observer = new MutationObserver(function (mutations) { 248 | mutations.forEach(function (mutation) { 249 | fn.call(_this3, mutation.target, mutation.addedNodes, mutation.removedNodes); 250 | }); 251 | }); 252 | observer.observe(ele, config); 253 | }); 254 | return this; 255 | } 256 | }, { 257 | key: 'attr', 258 | value: function (_attr) { 259 | function attr(_x, _x2) { 260 | return _attr.apply(this, arguments); 261 | } 262 | 263 | attr.toString = function () { 264 | return _attr.toString(); 265 | }; 266 | 267 | return attr; 268 | }(function (attr, value) { 269 | // one agm 270 | if (arguments.length === 1) { 271 | // get attr value 272 | if (typeof attr === 'string') { 273 | return this[0].getAttribute(attr); 274 | } 275 | // set attr with a json 276 | else if ((typeof attr === 'undefined' ? 'undefined' : _typeof(attr)) === 'object') { 277 | this.each(function (ele) { 278 | for (var at in attr) { 279 | if (attr.hasOwnProperty(at)) { 280 | ele.setAttribute(at, value); 281 | } 282 | } 283 | }); 284 | return value; 285 | } 286 | } 287 | // set 288 | else if (arguments.length === 2) { 289 | this.each(function (ele) { 290 | ele.setAttribute(attr, value); 291 | }); 292 | return this; 293 | } else { 294 | return this; 295 | } 296 | }) 297 | }, { 298 | key: 'removeAttr', 299 | value: function removeAttr(attr) { 300 | if (arguments.length === 1) { 301 | this.each(function (ele) { 302 | ele.removeAttribute(attr); 303 | }); 304 | } 305 | return this; 306 | } 307 | }, { 308 | key: 'remove', 309 | value: function remove() { 310 | this.each(function (ele) { 311 | ele.remove(); 312 | }); 313 | this.length = 0; 314 | return this; 315 | } 316 | 317 | // get the element style 318 | 319 | }, { 320 | key: 'style', 321 | value: function style(attr) { 322 | return this[0].currentStyle ? this[0].currentStyle[attr] : getComputedStyle(this[0])[attr]; 323 | } 324 | 325 | // (attr,value) || 'string' || {} 326 | 327 | }, { 328 | key: 'css', 329 | value: function css() { 330 | for (var _len = arguments.length, agm = Array(_len), _key = 0; _key < _len; _key++) { 331 | agm[_key] = arguments[_key]; 332 | } 333 | 334 | if (agm.length === 1) { 335 | // get style 336 | if (typeof agm[0] === 'string') { 337 | // set style as a long text 338 | if (/:/ig.test(agm[0])) { 339 | this.each(function (ele) { 340 | ele.style.cssText = attr; 341 | }); 342 | } else { 343 | return this[0].currentStyle ? this[0].currentStyle[agm[0]] : getComputedStyle(this[0])[agm[0]]; 344 | } 345 | } 346 | // set style as a object 347 | else { 348 | this.each(function (ele) { 349 | for (var _attr2 in agm[0]) { 350 | if (agm[0].hasOwnProperty(_attr2)) { 351 | ele.style[_attr2] = agm[0][_attr2]; 352 | } 353 | } 354 | }); 355 | } 356 | } 357 | // set as (key,value) 358 | else if (agm.length === 2) { 359 | this.each(function (ele) { 360 | ele.style[agm[0]] = agm[1]; 361 | }); 362 | } 363 | return this; 364 | } 365 | }, { 366 | key: 'width', 367 | value: function width(value) { 368 | var element = this[0]; 369 | // window or document 370 | if (element.window === element || element.body) { 371 | return document.body.scrollWidth > document.documentElement.scrollWidth ? document.body.scrollWidth : document.documentElement.scrollWidth; 372 | } 373 | // set width 374 | else if (value) { 375 | this.each(function (ele) { 376 | ele.style.width = value + 'px'; 377 | }); 378 | return this; 379 | } 380 | // get width 381 | else { 382 | return this[0].offsetWidth || parseFloat(this.style('width')); 383 | } 384 | } 385 | }, { 386 | key: 'height', 387 | value: function height(value) { 388 | var ele = this[0]; 389 | // window or document 390 | if (ele.window === ele || ele.body) { 391 | return document.body.scrollHeight > document.documentElement.scrollHeight ? document.body.scrollHeight : document.documentElement.scrollHeight; 392 | } 393 | // set height 394 | else if (value) { 395 | this.each(function (ele) { 396 | ele.style.height = value + 'px'; 397 | }); 398 | return this; 399 | } 400 | // get height 401 | else { 402 | return this[0].offsetHeight || parseFloat(this.style('height')); 403 | } 404 | } 405 | }, { 406 | key: 'html', 407 | value: function html(value) { 408 | if (value !== undefined) { 409 | this.each(function (ele) { 410 | ele.innerHTML = typeof value === 'function' ? value(ele) : value; 411 | }); 412 | } else { 413 | return this[0].innerHTML; 414 | } 415 | return this; 416 | } 417 | }, { 418 | key: 'text', 419 | value: function text(value) { 420 | if (value === undefined) return this[0].innerText || this[0].textContent; 421 | 422 | this.each(function (ele) { 423 | ele.innerText = ele.textContent = value; 424 | }); 425 | return this; 426 | } 427 | }, { 428 | key: 'val', 429 | value: function val(value) { 430 | if (value === undefined) return this[0].value; 431 | this.each(function (ele) { 432 | ele.value = value; 433 | }); 434 | return this; 435 | } 436 | }, { 437 | key: 'show', 438 | value: function show() { 439 | this.each(function (ele) { 440 | ele.style.display = ''; 441 | }); 442 | return this; 443 | } 444 | }, { 445 | key: 'hide', 446 | value: function hide() { 447 | this.each(function (ele) { 448 | ele.style.display = 'none'; 449 | }); 450 | return this; 451 | } 452 | 453 | // content str || jqLite Object || DOM 454 | // here is jqLite Object 455 | 456 | }, { 457 | key: 'append', 458 | value: function append(content) { 459 | this.each(function (ele) { 460 | ele.appendChild(content[0]); 461 | }); 462 | return this; 463 | } 464 | }, { 465 | key: 'prepend', 466 | 467 | 468 | // content str || jqLite Object || DOM 469 | // here is jqLite Object 470 | value: function prepend(content) { 471 | this.each(function (ele) { 472 | ele.insertBefore(content[0], ele.children[0]); 473 | }); 474 | return this; 475 | } 476 | }, { 477 | key: 'hasClass', 478 | value: function hasClass(className) { 479 | if (!this[0]) return false; 480 | return this[0].classList.contains(className); 481 | } 482 | }, { 483 | key: 'addClass', 484 | value: function addClass(className) { 485 | this.each(function (ele) { 486 | ele.classList.add(className); 487 | }); 488 | return this; 489 | } 490 | }, { 491 | key: 'removeClass', 492 | value: function removeClass(className) { 493 | this.each(function (ele) { 494 | ele.classList.remove(className); 495 | }); 496 | return this; 497 | } 498 | }, { 499 | key: 'index', 500 | get: function get() { 501 | var index = 0; 502 | var brothers = this[0].parentNode.children; 503 | for (var i = 0; i < brothers.length; i++) { 504 | if (brothers[i] == this[0]) { 505 | index = i; 506 | break; 507 | } 508 | } 509 | return index; 510 | } 511 | }], [{ 512 | key: 'fn', 513 | get: function get() { 514 | var visible = function visible(ele) { 515 | var pos = ele.getBoundingClientRect(); 516 | var w = void 0; 517 | var h = void 0; 518 | var inViewPort = void 0; 519 | var docEle = document.documentElement; 520 | var docBody = document.body; 521 | if (docEle.getBoundingClientRect) { 522 | w = docEle.clientWidth || docBody.clientWidth; 523 | h = docEle.clientHeight || docBody.clientHeight; 524 | inViewPort = pos.top > h || pos.bottom < 0 || pos.left > w || pos.right < 0; 525 | return inViewPort ? false : true; 526 | } 527 | }; 528 | var merge = function merge() { 529 | for (var _len2 = arguments.length, sources = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { 530 | sources[_key2] = arguments[_key2]; 531 | } 532 | 533 | return Object.assign.apply(Object, [{}].concat(sources)); 534 | }; 535 | return { 536 | visible: visible, 537 | merge: merge 538 | }; 539 | } 540 | }]); 541 | 542 | return jqLite; 543 | }(); 544 | 545 | var $ = function $() { 546 | var selectors = arguments.length <= 0 || arguments[0] === undefined ? '' : arguments[0]; 547 | var context = arguments.length <= 1 || arguments[1] === undefined ? document : arguments[1]; 548 | 549 | return new jqLite(selectors, context); 550 | }; 551 | $.fn = jqLite.fn; 552 | 553 | exports.default = $; 554 | 555 | /***/ }, 556 | /* 2 */ 557 | /***/ function(module, exports, __webpack_require__) { 558 | 559 | 'use strict'; 560 | var ctx = __webpack_require__(3) 561 | , $export = __webpack_require__(5) 562 | , toObject = __webpack_require__(15) 563 | , call = __webpack_require__(17) 564 | , isArrayIter = __webpack_require__(20) 565 | , toLength = __webpack_require__(24) 566 | , getIterFn = __webpack_require__(26); 567 | $export($export.S + $export.F * !__webpack_require__(29)(function(iter){ Array.from(iter); }), 'Array', { 568 | // 22.1.2.1 Array.from(arrayLike, mapfn = undefined, thisArg = undefined) 569 | from: function from(arrayLike/*, mapfn = undefined, thisArg = undefined*/){ 570 | var O = toObject(arrayLike) 571 | , C = typeof this == 'function' ? this : Array 572 | , $$ = arguments 573 | , $$len = $$.length 574 | , mapfn = $$len > 1 ? $$[1] : undefined 575 | , mapping = mapfn !== undefined 576 | , index = 0 577 | , iterFn = getIterFn(O) 578 | , length, result, step, iterator; 579 | if(mapping)mapfn = ctx(mapfn, $$len > 2 ? $$[2] : undefined, 2); 580 | // if object isn't iterable or it's array with default iterator - use simple case 581 | if(iterFn != undefined && !(C == Array && isArrayIter(iterFn))){ 582 | for(iterator = iterFn.call(O), result = new C; !(step = iterator.next()).done; index++){ 583 | result[index] = mapping ? call(iterator, mapfn, [step.value, index], true) : step.value; 584 | } 585 | } else { 586 | length = toLength(O.length); 587 | for(result = new C(length); length > index; index++){ 588 | result[index] = mapping ? mapfn(O[index], index) : O[index]; 589 | } 590 | } 591 | result.length = index; 592 | return result; 593 | } 594 | }); 595 | 596 | 597 | /***/ }, 598 | /* 3 */ 599 | /***/ function(module, exports, __webpack_require__) { 600 | 601 | // optional / simple context binding 602 | var aFunction = __webpack_require__(4); 603 | module.exports = function(fn, that, length){ 604 | aFunction(fn); 605 | if(that === undefined)return fn; 606 | switch(length){ 607 | case 1: return function(a){ 608 | return fn.call(that, a); 609 | }; 610 | case 2: return function(a, b){ 611 | return fn.call(that, a, b); 612 | }; 613 | case 3: return function(a, b, c){ 614 | return fn.call(that, a, b, c); 615 | }; 616 | } 617 | return function(/* ...args */){ 618 | return fn.apply(that, arguments); 619 | }; 620 | }; 621 | 622 | /***/ }, 623 | /* 4 */ 624 | /***/ function(module, exports) { 625 | 626 | module.exports = function(it){ 627 | if(typeof it != 'function')throw TypeError(it + ' is not a function!'); 628 | return it; 629 | }; 630 | 631 | /***/ }, 632 | /* 5 */ 633 | /***/ function(module, exports, __webpack_require__) { 634 | 635 | var global = __webpack_require__(6) 636 | , core = __webpack_require__(7) 637 | , hide = __webpack_require__(8) 638 | , redefine = __webpack_require__(13) 639 | , ctx = __webpack_require__(3) 640 | , PROTOTYPE = 'prototype'; 641 | 642 | var $export = function(type, name, source){ 643 | var IS_FORCED = type & $export.F 644 | , IS_GLOBAL = type & $export.G 645 | , IS_STATIC = type & $export.S 646 | , IS_PROTO = type & $export.P 647 | , IS_BIND = type & $export.B 648 | , target = IS_GLOBAL ? global : IS_STATIC ? global[name] || (global[name] = {}) : (global[name] || {})[PROTOTYPE] 649 | , exports = IS_GLOBAL ? core : core[name] || (core[name] = {}) 650 | , expProto = exports[PROTOTYPE] || (exports[PROTOTYPE] = {}) 651 | , key, own, out, exp; 652 | if(IS_GLOBAL)source = name; 653 | for(key in source){ 654 | // contains in native 655 | own = !IS_FORCED && target && key in target; 656 | // export native or passed 657 | out = (own ? target : source)[key]; 658 | // bind timers to global for call from export context 659 | exp = IS_BIND && own ? ctx(out, global) : IS_PROTO && typeof out == 'function' ? ctx(Function.call, out) : out; 660 | // extend global 661 | if(target && !own)redefine(target, key, out); 662 | // export 663 | if(exports[key] != out)hide(exports, key, exp); 664 | if(IS_PROTO && expProto[key] != out)expProto[key] = out; 665 | } 666 | }; 667 | global.core = core; 668 | // type bitmap 669 | $export.F = 1; // forced 670 | $export.G = 2; // global 671 | $export.S = 4; // static 672 | $export.P = 8; // proto 673 | $export.B = 16; // bind 674 | $export.W = 32; // wrap 675 | module.exports = $export; 676 | 677 | /***/ }, 678 | /* 6 */ 679 | /***/ function(module, exports) { 680 | 681 | // https://github.com/zloirock/core-js/issues/86#issuecomment-115759028 682 | var global = module.exports = typeof window != 'undefined' && window.Math == Math 683 | ? window : typeof self != 'undefined' && self.Math == Math ? self : Function('return this')(); 684 | if(typeof __g == 'number')__g = global; // eslint-disable-line no-undef 685 | 686 | /***/ }, 687 | /* 7 */ 688 | /***/ function(module, exports) { 689 | 690 | var core = module.exports = {version: '1.2.6'}; 691 | if(typeof __e == 'number')__e = core; // eslint-disable-line no-undef 692 | 693 | /***/ }, 694 | /* 8 */ 695 | /***/ function(module, exports, __webpack_require__) { 696 | 697 | var $ = __webpack_require__(9) 698 | , createDesc = __webpack_require__(10); 699 | module.exports = __webpack_require__(11) ? function(object, key, value){ 700 | return $.setDesc(object, key, createDesc(1, value)); 701 | } : function(object, key, value){ 702 | object[key] = value; 703 | return object; 704 | }; 705 | 706 | /***/ }, 707 | /* 9 */ 708 | /***/ function(module, exports) { 709 | 710 | var $Object = Object; 711 | module.exports = { 712 | create: $Object.create, 713 | getProto: $Object.getPrototypeOf, 714 | isEnum: {}.propertyIsEnumerable, 715 | getDesc: $Object.getOwnPropertyDescriptor, 716 | setDesc: $Object.defineProperty, 717 | setDescs: $Object.defineProperties, 718 | getKeys: $Object.keys, 719 | getNames: $Object.getOwnPropertyNames, 720 | getSymbols: $Object.getOwnPropertySymbols, 721 | each: [].forEach 722 | }; 723 | 724 | /***/ }, 725 | /* 10 */ 726 | /***/ function(module, exports) { 727 | 728 | module.exports = function(bitmap, value){ 729 | return { 730 | enumerable : !(bitmap & 1), 731 | configurable: !(bitmap & 2), 732 | writable : !(bitmap & 4), 733 | value : value 734 | }; 735 | }; 736 | 737 | /***/ }, 738 | /* 11 */ 739 | /***/ function(module, exports, __webpack_require__) { 740 | 741 | // Thank's IE8 for his funny defineProperty 742 | module.exports = !__webpack_require__(12)(function(){ 743 | return Object.defineProperty({}, 'a', {get: function(){ return 7; }}).a != 7; 744 | }); 745 | 746 | /***/ }, 747 | /* 12 */ 748 | /***/ function(module, exports) { 749 | 750 | module.exports = function(exec){ 751 | try { 752 | return !!exec(); 753 | } catch(e){ 754 | return true; 755 | } 756 | }; 757 | 758 | /***/ }, 759 | /* 13 */ 760 | /***/ function(module, exports, __webpack_require__) { 761 | 762 | // add fake Function#toString 763 | // for correct work wrapped methods / constructors with methods like LoDash isNative 764 | var global = __webpack_require__(6) 765 | , hide = __webpack_require__(8) 766 | , SRC = __webpack_require__(14)('src') 767 | , TO_STRING = 'toString' 768 | , $toString = Function[TO_STRING] 769 | , TPL = ('' + $toString).split(TO_STRING); 770 | 771 | __webpack_require__(7).inspectSource = function(it){ 772 | return $toString.call(it); 773 | }; 774 | 775 | (module.exports = function(O, key, val, safe){ 776 | if(typeof val == 'function'){ 777 | val.hasOwnProperty(SRC) || hide(val, SRC, O[key] ? '' + O[key] : TPL.join(String(key))); 778 | val.hasOwnProperty('name') || hide(val, 'name', key); 779 | } 780 | if(O === global){ 781 | O[key] = val; 782 | } else { 783 | if(!safe)delete O[key]; 784 | hide(O, key, val); 785 | } 786 | })(Function.prototype, TO_STRING, function toString(){ 787 | return typeof this == 'function' && this[SRC] || $toString.call(this); 788 | }); 789 | 790 | /***/ }, 791 | /* 14 */ 792 | /***/ function(module, exports) { 793 | 794 | var id = 0 795 | , px = Math.random(); 796 | module.exports = function(key){ 797 | return 'Symbol('.concat(key === undefined ? '' : key, ')_', (++id + px).toString(36)); 798 | }; 799 | 800 | /***/ }, 801 | /* 15 */ 802 | /***/ function(module, exports, __webpack_require__) { 803 | 804 | // 7.1.13 ToObject(argument) 805 | var defined = __webpack_require__(16); 806 | module.exports = function(it){ 807 | return Object(defined(it)); 808 | }; 809 | 810 | /***/ }, 811 | /* 16 */ 812 | /***/ function(module, exports) { 813 | 814 | // 7.2.1 RequireObjectCoercible(argument) 815 | module.exports = function(it){ 816 | if(it == undefined)throw TypeError("Can't call method on " + it); 817 | return it; 818 | }; 819 | 820 | /***/ }, 821 | /* 17 */ 822 | /***/ function(module, exports, __webpack_require__) { 823 | 824 | // call something on iterator step with safe closing on error 825 | var anObject = __webpack_require__(18); 826 | module.exports = function(iterator, fn, value, entries){ 827 | try { 828 | return entries ? fn(anObject(value)[0], value[1]) : fn(value); 829 | // 7.4.6 IteratorClose(iterator, completion) 830 | } catch(e){ 831 | var ret = iterator['return']; 832 | if(ret !== undefined)anObject(ret.call(iterator)); 833 | throw e; 834 | } 835 | }; 836 | 837 | /***/ }, 838 | /* 18 */ 839 | /***/ function(module, exports, __webpack_require__) { 840 | 841 | var isObject = __webpack_require__(19); 842 | module.exports = function(it){ 843 | if(!isObject(it))throw TypeError(it + ' is not an object!'); 844 | return it; 845 | }; 846 | 847 | /***/ }, 848 | /* 19 */ 849 | /***/ function(module, exports) { 850 | 851 | module.exports = function(it){ 852 | return typeof it === 'object' ? it !== null : typeof it === 'function'; 853 | }; 854 | 855 | /***/ }, 856 | /* 20 */ 857 | /***/ function(module, exports, __webpack_require__) { 858 | 859 | // check on default Array iterator 860 | var Iterators = __webpack_require__(21) 861 | , ITERATOR = __webpack_require__(22)('iterator') 862 | , ArrayProto = Array.prototype; 863 | 864 | module.exports = function(it){ 865 | return it !== undefined && (Iterators.Array === it || ArrayProto[ITERATOR] === it); 866 | }; 867 | 868 | /***/ }, 869 | /* 21 */ 870 | /***/ function(module, exports) { 871 | 872 | module.exports = {}; 873 | 874 | /***/ }, 875 | /* 22 */ 876 | /***/ function(module, exports, __webpack_require__) { 877 | 878 | var store = __webpack_require__(23)('wks') 879 | , uid = __webpack_require__(14) 880 | , Symbol = __webpack_require__(6).Symbol; 881 | module.exports = function(name){ 882 | return store[name] || (store[name] = 883 | Symbol && Symbol[name] || (Symbol || uid)('Symbol.' + name)); 884 | }; 885 | 886 | /***/ }, 887 | /* 23 */ 888 | /***/ function(module, exports, __webpack_require__) { 889 | 890 | var global = __webpack_require__(6) 891 | , SHARED = '__core-js_shared__' 892 | , store = global[SHARED] || (global[SHARED] = {}); 893 | module.exports = function(key){ 894 | return store[key] || (store[key] = {}); 895 | }; 896 | 897 | /***/ }, 898 | /* 24 */ 899 | /***/ function(module, exports, __webpack_require__) { 900 | 901 | // 7.1.15 ToLength 902 | var toInteger = __webpack_require__(25) 903 | , min = Math.min; 904 | module.exports = function(it){ 905 | return it > 0 ? min(toInteger(it), 0x1fffffffffffff) : 0; // pow(2, 53) - 1 == 9007199254740991 906 | }; 907 | 908 | /***/ }, 909 | /* 25 */ 910 | /***/ function(module, exports) { 911 | 912 | // 7.1.4 ToInteger 913 | var ceil = Math.ceil 914 | , floor = Math.floor; 915 | module.exports = function(it){ 916 | return isNaN(it = +it) ? 0 : (it > 0 ? floor : ceil)(it); 917 | }; 918 | 919 | /***/ }, 920 | /* 26 */ 921 | /***/ function(module, exports, __webpack_require__) { 922 | 923 | var classof = __webpack_require__(27) 924 | , ITERATOR = __webpack_require__(22)('iterator') 925 | , Iterators = __webpack_require__(21); 926 | module.exports = __webpack_require__(7).getIteratorMethod = function(it){ 927 | if(it != undefined)return it[ITERATOR] 928 | || it['@@iterator'] 929 | || Iterators[classof(it)]; 930 | }; 931 | 932 | /***/ }, 933 | /* 27 */ 934 | /***/ function(module, exports, __webpack_require__) { 935 | 936 | // getting tag from 19.1.3.6 Object.prototype.toString() 937 | var cof = __webpack_require__(28) 938 | , TAG = __webpack_require__(22)('toStringTag') 939 | // ES3 wrong here 940 | , ARG = cof(function(){ return arguments; }()) == 'Arguments'; 941 | 942 | module.exports = function(it){ 943 | var O, T, B; 944 | return it === undefined ? 'Undefined' : it === null ? 'Null' 945 | // @@toStringTag case 946 | : typeof (T = (O = Object(it))[TAG]) == 'string' ? T 947 | // builtinTag case 948 | : ARG ? cof(O) 949 | // ES3 arguments fallback 950 | : (B = cof(O)) == 'Object' && typeof O.callee == 'function' ? 'Arguments' : B; 951 | }; 952 | 953 | /***/ }, 954 | /* 28 */ 955 | /***/ function(module, exports) { 956 | 957 | var toString = {}.toString; 958 | 959 | module.exports = function(it){ 960 | return toString.call(it).slice(8, -1); 961 | }; 962 | 963 | /***/ }, 964 | /* 29 */ 965 | /***/ function(module, exports, __webpack_require__) { 966 | 967 | var ITERATOR = __webpack_require__(22)('iterator') 968 | , SAFE_CLOSING = false; 969 | 970 | try { 971 | var riter = [7][ITERATOR](); 972 | riter['return'] = function(){ SAFE_CLOSING = true; }; 973 | Array.from(riter, function(){ throw 2; }); 974 | } catch(e){ /* empty */ } 975 | 976 | module.exports = function(exec, skipClosing){ 977 | if(!skipClosing && !SAFE_CLOSING)return false; 978 | var safe = false; 979 | try { 980 | var arr = [7] 981 | , iter = arr[ITERATOR](); 982 | iter.next = function(){ safe = true; }; 983 | arr[ITERATOR] = function(){ return iter; }; 984 | exec(arr); 985 | } catch(e){ /* empty */ } 986 | return safe; 987 | }; 988 | 989 | /***/ }, 990 | /* 30 */ 991 | /***/ function(module, exports, __webpack_require__) { 992 | 993 | // 19.1.3.1 Object.assign(target, source) 994 | var $export = __webpack_require__(5); 995 | 996 | $export($export.S + $export.F, 'Object', {assign: __webpack_require__(31)}); 997 | 998 | /***/ }, 999 | /* 31 */ 1000 | /***/ function(module, exports, __webpack_require__) { 1001 | 1002 | // 19.1.2.1 Object.assign(target, source, ...) 1003 | var $ = __webpack_require__(9) 1004 | , toObject = __webpack_require__(15) 1005 | , IObject = __webpack_require__(32); 1006 | 1007 | // should work with symbols and should have deterministic property order (V8 bug) 1008 | module.exports = __webpack_require__(12)(function(){ 1009 | var a = Object.assign 1010 | , A = {} 1011 | , B = {} 1012 | , S = Symbol() 1013 | , K = 'abcdefghijklmnopqrst'; 1014 | A[S] = 7; 1015 | K.split('').forEach(function(k){ B[k] = k; }); 1016 | return a({}, A)[S] != 7 || Object.keys(a({}, B)).join('') != K; 1017 | }) ? function assign(target, source){ // eslint-disable-line no-unused-vars 1018 | var T = toObject(target) 1019 | , $$ = arguments 1020 | , $$len = $$.length 1021 | , index = 1 1022 | , getKeys = $.getKeys 1023 | , getSymbols = $.getSymbols 1024 | , isEnum = $.isEnum; 1025 | while($$len > index){ 1026 | var S = IObject($$[index++]) 1027 | , keys = getSymbols ? getKeys(S).concat(getSymbols(S)) : getKeys(S) 1028 | , length = keys.length 1029 | , j = 0 1030 | , key; 1031 | while(length > j)if(isEnum.call(S, key = keys[j++]))T[key] = S[key]; 1032 | } 1033 | return T; 1034 | } : Object.assign; 1035 | 1036 | /***/ }, 1037 | /* 32 */ 1038 | /***/ function(module, exports, __webpack_require__) { 1039 | 1040 | // fallback for non-array-like ES3 and non-enumerable old V8 strings 1041 | var cof = __webpack_require__(28); 1042 | module.exports = Object('z').propertyIsEnumerable(0) ? Object : function(it){ 1043 | return cof(it) == 'String' ? it.split('') : Object(it); 1044 | }; 1045 | 1046 | /***/ }, 1047 | /* 33 */, 1048 | /* 34 */, 1049 | /* 35 */, 1050 | /* 36 */, 1051 | /* 37 */, 1052 | /* 38 */, 1053 | /* 39 */, 1054 | /* 40 */, 1055 | /* 41 */, 1056 | /* 42 */, 1057 | /* 43 */, 1058 | /* 44 */, 1059 | /* 45 */, 1060 | /* 46 */, 1061 | /* 47 */, 1062 | /* 48 */, 1063 | /* 49 */, 1064 | /* 50 */, 1065 | /* 51 */ 1066 | /***/ function(module, exports) { 1067 | 1068 | "use strict"; 1069 | 1070 | Object.defineProperty(exports, "__esModule", { 1071 | value: true 1072 | }); 1073 | /* 1074 | * 频率控制 返回函数连续调用时,fn 执行频率限定为每多少时间执行一次 1075 | * @param fn {function} 需要调用的函数 1076 | * @param delay {number} 延迟时间,单位毫秒 1077 | * @param immediate {bool} 给 immediate参数传递false 绑定的函数先执行,而不是delay后后执行。 1078 | * @return {function}实际调用函数 1079 | */ 1080 | var $throttle = function $throttle(fn, delay, immediate, debounce) { 1081 | var curr = +new Date(), 1082 | //当前事件 1083 | last_call = 0, 1084 | last_exec = 0, 1085 | timer = null, 1086 | diff, 1087 | //时间差 1088 | context, 1089 | //上下文 1090 | args, 1091 | exec = function exec() { 1092 | last_exec = curr; 1093 | fn.apply(context, args); 1094 | }; 1095 | return function () { 1096 | curr = +new Date(); 1097 | context = this, args = arguments, diff = curr - (debounce ? last_call : last_exec) - delay; 1098 | clearTimeout(timer); 1099 | if (debounce) { 1100 | if (immediate) { 1101 | timer = setTimeout(exec, delay); 1102 | } else if (diff >= 0) { 1103 | exec(); 1104 | } 1105 | } else { 1106 | if (diff >= 0) { 1107 | exec(); 1108 | } else if (immediate) { 1109 | timer = setTimeout(exec, -diff); 1110 | } 1111 | } 1112 | last_call = curr; 1113 | }; 1114 | }; 1115 | 1116 | /* 1117 | * 空闲控制 返回函数连续调用时,空闲时间必须大于或等于 delay,fn 才会执行 1118 | * @param fn {function} 要调用的函数 1119 | * @param delay {number} 空闲时间 1120 | * @param immediate {bool} 给 immediate参数传递false 绑定的函数先执行,而不是delay后后执行。 1121 | * @return {function}实际调用函数 1122 | */ 1123 | 1124 | var $debounce = function $debounce(fn, delay, immediate) { 1125 | return $throttle(fn, delay, immediate, true); 1126 | }; 1127 | 1128 | exports.$debounce = $debounce; 1129 | exports.$throttle = $throttle; 1130 | 1131 | /***/ }, 1132 | /* 52 */, 1133 | /* 53 */, 1134 | /* 54 */, 1135 | /* 55 */, 1136 | /* 56 */, 1137 | /* 57 */, 1138 | /* 58 */, 1139 | /* 59 */, 1140 | /* 60 */ 1141 | /***/ function(module, exports, __webpack_require__) { 1142 | 1143 | 'use strict'; 1144 | 1145 | Object.defineProperty(exports, "__esModule", { 1146 | value: true 1147 | }); 1148 | 1149 | var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); 1150 | 1151 | var _jqLite = __webpack_require__(1); 1152 | 1153 | var _jqLite2 = _interopRequireDefault(_jqLite); 1154 | 1155 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 1156 | 1157 | function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } 1158 | 1159 | var Main = function () { 1160 | function Main() { 1161 | var _this = this; 1162 | 1163 | var agm = arguments.length <= 0 || arguments[0] === undefined ? '' : arguments[0]; 1164 | 1165 | _classCallCheck(this, Main); 1166 | 1167 | if (!agm) return this; 1168 | this.inViewPort = []; 1169 | 1170 | (0, _jqLite2.default)(agm).each(function (aEle) { 1171 | if (_jqLite2.default.fn.visible(aEle)) _this.inViewPort.push(aEle); 1172 | }); 1173 | } 1174 | 1175 | _createClass(Main, [{ 1176 | key: 'redirect', 1177 | value: function redirect() { 1178 | (0, _jqLite2.default)(this.inViewPort).each(function (aEle) { 1179 | if (!aEle || !aEle.href) return; 1180 | var href = aEle.href.trim().replace(/^.*link\.zhihu\.com\/\?target=(.*?)$/im, '$1').trim().replace(/^\s*http[^\/]*\/\//, 'http://'); 1181 | href = decodeURIComponent(href); 1182 | aEle.href = href; 1183 | }); 1184 | return this; 1185 | } 1186 | }]); 1187 | 1188 | return Main; 1189 | }(); 1190 | 1191 | exports.default = Main; 1192 | 1193 | /***/ } 1194 | /******/ ]); -------------------------------------------------------------------------------- /gulpfile.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by axetroy on 16-6-3. 3 | */ 4 | 5 | var gulp = require('gulp'); 6 | var $ = require('gulp-load-plugins')(); 7 | var scripts = require('./scripts/meta'); 8 | 9 | gulp.task('script', function () { 10 | return gulp.src('index.js') 11 | .pipe($.webpack(require('./webpack.config'))) 12 | .pipe(gulp.dest('.temp/')); 13 | }); 14 | 15 | gulp.task('build', ['script'], function () { 16 | 17 | scripts.forEach(v=> { 18 | gulp.src([ 19 | `src/${v.name}/meta.js`, 20 | `.temp/${v.name}.js` 21 | ]).pipe($.concat(`${v.name}.user.js`)) 22 | .pipe(gulp.dest('dist')); 23 | }); 24 | 25 | }); -------------------------------------------------------------------------------- /libs/$addStyle.js: -------------------------------------------------------------------------------- 1 | let addCssByStyle = (cssString) => { 2 | let doc = document; 3 | let style = doc.createElement("style"); 4 | style.setAttribute("type", "text/css"); 5 | style.setAttribute('id', 'remove_redirect_debug'); 6 | 7 | if (style.styleSheet) {// IE 8 | style.styleSheet.cssText = cssString; 9 | } else {// w3c 10 | let cssText = doc.createTextNode(cssString); 11 | style.appendChild(cssText); 12 | } 13 | 14 | let heads = doc.getElementsByTagName("head"); 15 | heads.length ? heads[0].appendChild(style) : doc.documentElement.appendChild(style); 16 | }; 17 | 18 | let $addStyle = (styleCSSText) => { 19 | let style = document.getElementById('remove_redirect_debug'); 20 | !style && addCssByStyle(styleCSSText); 21 | }; 22 | 23 | export default $addStyle; -------------------------------------------------------------------------------- /libs/$debounce.js: -------------------------------------------------------------------------------- 1 | /* 2 | * 频率控制 返回函数连续调用时,fn 执行频率限定为每多少时间执行一次 3 | * @param fn {function} 需要调用的函数 4 | * @param delay {number} 延迟时间,单位毫秒 5 | * @param immediate {bool} 给 immediate参数传递false 绑定的函数先执行,而不是delay后后执行。 6 | * @return {function}实际调用函数 7 | */ 8 | var $throttle = function (fn, delay, immediate, debounce) { 9 | var curr = +new Date(),//当前事件 10 | last_call = 0, 11 | last_exec = 0, 12 | timer = null, 13 | diff, //时间差 14 | context,//上下文 15 | args, 16 | exec = function () { 17 | last_exec = curr; 18 | fn.apply(context, args); 19 | }; 20 | return function () { 21 | curr = +new Date(); 22 | context = this, 23 | args = arguments, 24 | diff = curr - (debounce ? last_call : last_exec) - delay; 25 | clearTimeout(timer); 26 | if (debounce) { 27 | if (immediate) { 28 | timer = setTimeout(exec, delay); 29 | } else if (diff >= 0) { 30 | exec(); 31 | } 32 | } else { 33 | if (diff >= 0) { 34 | exec(); 35 | } else if (immediate) { 36 | timer = setTimeout(exec, -diff); 37 | } 38 | } 39 | last_call = curr; 40 | } 41 | }; 42 | 43 | /* 44 | * 空闲控制 返回函数连续调用时,空闲时间必须大于或等于 delay,fn 才会执行 45 | * @param fn {function} 要调用的函数 46 | * @param delay {number} 空闲时间 47 | * @param immediate {bool} 给 immediate参数传递false 绑定的函数先执行,而不是delay后后执行。 48 | * @return {function}实际调用函数 49 | */ 50 | 51 | var $debounce = function (fn, delay, immediate) { 52 | return $throttle(fn, delay, immediate, true); 53 | }; 54 | 55 | export {$debounce, $throttle}; -------------------------------------------------------------------------------- /libs/$http.js: -------------------------------------------------------------------------------- 1 | /** 2 | * http service 3 | * @param ops 4 | * @returns {Promise} 5 | */ 6 | 7 | let $q = require('q'); 8 | let $ = require('./jqLite'); 9 | let $util = require('./$util'); 10 | 11 | let $http = function (ops = {}) { 12 | let deferred = $q.defer(); 13 | 14 | let onreadystatechange = (response)=> { 15 | if (response.readyState !== 4) return; 16 | response.requestUrl = ops.url; 17 | if (/^(2|3)/.test(response.status) || response.finalUrl) { 18 | deferred.resolve(response); 19 | } 20 | else { 21 | deferred.reject(response); 22 | } 23 | }; 24 | 25 | let ontimeout = (response)=> { 26 | response.requestUrl = ops.url; 27 | response && response.finalUrl ? deferred.resolve(response) : deferred.reject(response); 28 | }; 29 | 30 | let onerror = (response)=> { 31 | response.requestUrl = ops.url; 32 | response && response.finalUrl ? deferred.resolve(response) : deferred.reject(response); 33 | }; 34 | 35 | ops = $util.merge({ 36 | onreadystatechange, 37 | ontimeout, 38 | onerror 39 | }, ops); 40 | 41 | // make the protocol agree 42 | if (!new RegExp(`^${window.location.protocol}`).test(ops.url)) { 43 | ops.url = ops.url.replace(/^(http|https):/im, window.location.protocol); 44 | } 45 | 46 | GM_xmlhttpRequest(ops); 47 | return deferred.promise; 48 | }; 49 | 50 | ['HEAD', 'GET', 'POST'].forEach(function (method) { 51 | $http[method.toLocaleLowerCase()] = function (url, ops = {}) { 52 | var deferred = $q.defer(); 53 | ops = $util.merge(ops, {url, method: method}); 54 | $http(ops) 55 | .then(function (response) { 56 | deferred.resolve(response); 57 | }, function (response) { 58 | deferred.reject(response); 59 | }); 60 | return deferred.promise; 61 | } 62 | }); 63 | 64 | $http.jsonp = (url)=> { 65 | let deferred = $q.defer(); 66 | 67 | let func = function (resp) { 68 | script.remove(); 69 | resp ? deferred.resolve(resp) : deferred.reject(resp); 70 | }; 71 | 72 | let script = document.createElement('script'); 73 | script.setAttribute("type", "text/javascript"); 74 | script.src = url + '?callback=func'; 75 | document.body.appendChild(script); 76 | 77 | return deferred.promise; 78 | }; 79 | 80 | export default $http; -------------------------------------------------------------------------------- /libs/$interval.js: -------------------------------------------------------------------------------- 1 | let $interval = (fn, delay) => { 2 | let interval = () => { 3 | fn.call(this); 4 | id = setTimeout(interval, delay); 5 | }; 6 | 7 | let id = setTimeout(interval, delay); 8 | 9 | return function () { 10 | window.clearTimeout(id); 11 | } 12 | }; 13 | 14 | $interval.cancel = (timerFunc) => { 15 | timerFunc(); 16 | }; 17 | 18 | export default $interval; -------------------------------------------------------------------------------- /libs/$timeout.js: -------------------------------------------------------------------------------- 1 | /** 2 | * timeout wrapper 3 | * @param fn 4 | * @param delay 5 | * @returns {number} 6 | */ 7 | let $timeout = (fn = noop, delay = 0) => { 8 | return window.setTimeout(fn, delay); 9 | }; 10 | 11 | /** 12 | * cancel timer 13 | * @param timerId 14 | * @returns {*} 15 | */ 16 | $timeout.cancel = function (timerId) { 17 | window.clearTimeout(timerId); 18 | return timerId; 19 | }; 20 | 21 | export default $timeout; 22 | -------------------------------------------------------------------------------- /libs/$util.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by axetroy on 16-4-17. 3 | */ 4 | 5 | // object.assign for merge and copy 6 | import 'babel-polyfill/node_modules/babel-runtime/node_modules/core-js/modules/es6.object.assign'; 7 | 8 | const TYPED_ARRAY_REGEXP = /^\[object (?:Uint8|Uint8Clamped|Uint16|Uint32|Int8|Int16|Int32|Float32|Float64)Array\]$/; 9 | 10 | let noop; 11 | let toString = Object.prototype.toString; 12 | let createMap; 13 | let equals; 14 | let merge; 15 | let extend; 16 | let copy; 17 | 18 | let isDefined; 19 | let isUndefined; 20 | let isArray; 21 | let isDate; 22 | let isBoolean; 23 | let isElement; 24 | let isNumber; 25 | let isObject; 26 | let isString; 27 | let isFunction; 28 | let isRegExp; 29 | let isWindow; 30 | let isFile; 31 | let isBlob; 32 | let isTypedArray; 33 | let isArrayBuffer; 34 | 35 | noop = ()=> { 36 | }; 37 | 38 | createMap = () => { 39 | return Object.create(null); 40 | }; 41 | 42 | isDefined = ($$defined)=> { 43 | return !isUndefined($$defined); 44 | }; 45 | isUndefined = (value, undefined)=> { 46 | return typeof value === 'undefined' || value === undefined; 47 | }; 48 | isArray = Array.isArray; 49 | isDate = (date)=> { 50 | return toString.call(date) === '[object Date]' 51 | }; 52 | isBoolean = (value)=> { 53 | return typeof value === 'boolean' || value instanceof Boolean; 54 | }; 55 | isElement = (node)=> { 56 | return !!(node && (node.nodeName || (node.prop && node.attr))); 57 | }; 58 | isNumber = (value)=> { 59 | return isNaN(value) ? false : typeof value === 'number' || value instanceof Number; 60 | }; 61 | isObject = (value)=> { 62 | return value !== null && typeof value === 'object'; 63 | }; 64 | isString = (value)=> { 65 | return typeof value === 'string' || value instanceof String; 66 | }; 67 | isFunction = (value)=> { 68 | return typeof value === 'function'; 69 | }; 70 | isRegExp = (value)=> { 71 | return toString.call(value) === '[object RegExp]'; 72 | }; 73 | isWindow = (obj)=> { 74 | return obj && obj.window === obj; 75 | }; 76 | isFile = (obj)=> { 77 | return toString.call(obj) === '[object File]'; 78 | }; 79 | isBlob = (obj)=> { 80 | return toString.call(obj) === '[object Blob]'; 81 | }; 82 | isTypedArray = (value)=> { 83 | return value && isNumber(value.length) && TYPED_ARRAY_REGEXP.test(toString.call(value)); 84 | }; 85 | isArrayBuffer = (obj)=> { 86 | return toString.call(obj) === '[object ArrayBuffer]'; 87 | }; 88 | 89 | equals = (o1, o2)=> { 90 | if (o1 === o2) return true; 91 | if (o1 === null || o2 === null) return false; 92 | if (o1 !== o1 && o2 !== o2) return true; // NaN === NaN 93 | var t1 = typeof o1, t2 = typeof o2; 94 | if (t1 === t2 && t1 === 'object') { 95 | // array 96 | if (isArray(o1)) { 97 | if (!isArray(o2)) return false; 98 | let length = o1.length; 99 | if (length === o2.length) { 100 | for (let key = 0; key < length; key++) { 101 | if (!equals(o1[key], o2[key])) return false; 102 | } 103 | return true; 104 | } 105 | } 106 | //date 107 | else if (isDate(o1)) { 108 | if (!isDate(o2)) return false; 109 | return equals(o1.getTime(), o2.getTime()); 110 | } 111 | // RegExp 112 | else if (isRegExp(o1)) { 113 | if (!isRegExp(o2)) return false; 114 | return o1.toString() === o2.toString(); 115 | } 116 | else { 117 | if (isWindow(o1) || isWindow(o2)) return false; 118 | 119 | for (let attr in o2) { 120 | if (o2.hasOwnProperty(attr)) { 121 | if (!attr in o1 || o2[attr] !== o1[attr]) return false; 122 | } 123 | } 124 | 125 | return true; 126 | } 127 | } 128 | else if (t1 === 'function') { 129 | if (t2 !== 'function') return false; 130 | return o1.toString() === o2.toString(); 131 | } 132 | else { 133 | return o1 === o2; 134 | } 135 | return false; 136 | }; 137 | 138 | merge = (...sources)=> { 139 | return Object.assign({}, ...sources); 140 | }; 141 | 142 | extend = (target, ...source)=> { 143 | return Object.assign(target, ...source); 144 | }; 145 | 146 | copy = (obj)=> { 147 | return merge(obj); 148 | }; 149 | 150 | 151 | module.exports = { 152 | noop, 153 | isDefined, 154 | isUndefined, 155 | isArray, 156 | isDate, 157 | isBoolean, 158 | isElement, 159 | isNumber, 160 | isObject, 161 | isString, 162 | isFunction, 163 | isRegExp, 164 | isWindow, 165 | isFile, 166 | isBlob, 167 | isTypedArray, 168 | isArrayBuffer, 169 | equals, 170 | merge, 171 | extend, 172 | copy 173 | }; -------------------------------------------------------------------------------- /libs/jqLite.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | // es6 Array.from 4 | import 'babel-polyfill/node_modules/babel-runtime/node_modules/core-js/modules/es6.array.from'; 5 | // es6 Object.assign 6 | import 'babel-polyfill/node_modules/babel-runtime/node_modules/core-js/modules/es6.object.assign'; 7 | 8 | let noop = x => x; 9 | 10 | class jqLite { 11 | constructor(selectors = '', context = document) { 12 | this.selectors = selectors; 13 | this.context = context; 14 | this.length = 0; 15 | 16 | switch (typeof selectors) { 17 | case 'undefined': 18 | break; 19 | case 'string': 20 | Array.from(context.querySelectorAll(selectors), (ele, i) => { 21 | this[i] = ele; 22 | this.length++; 23 | }, this); 24 | break; 25 | case 'object': 26 | if (selectors.length) { 27 | Array.from(selectors, (ele, i) => { 28 | this[i] = ele; 29 | this.length++; 30 | }, this); 31 | } else { 32 | this[0] = selectors; 33 | this.length = 1; 34 | } 35 | break; 36 | case 'function': 37 | this.ready(selectors); 38 | break; 39 | default: 40 | 41 | } 42 | 43 | }; 44 | 45 | eq(n = 0) { 46 | return new jqLite(this[n]); 47 | } 48 | 49 | find(selectors) { 50 | return new jqLite(selectors, this[0]); 51 | } 52 | 53 | each(fn = noop) { 54 | for (let i = 0; i < this.length; i++) { 55 | fn.call(this, this[i], i); 56 | } 57 | return this; 58 | }; 59 | 60 | bind(types = '', fn = noop) { 61 | this.each((ele)=> { 62 | types.trim().split(/\s{1,}/).forEach((type)=> { 63 | ele.addEventListener(type, (e) => { 64 | let target = e.target || e.srcElement; 65 | if (fn.call(target, e) === false) { 66 | e.returnValue = true; 67 | e.cancelBubble = true; 68 | e.preventDefault && e.preventDefault(); 69 | e.stopPropagation && e.stopPropagation(); 70 | return false; 71 | } 72 | }, false); 73 | }); 74 | }); 75 | }; 76 | 77 | click(fn = noop) { 78 | this.bind('click', fn); 79 | return this; 80 | }; 81 | 82 | ready(fn = noop) { 83 | window.addEventListener('DOMContentLoaded', e => { 84 | fn.call(this, e); 85 | }, false); 86 | } 87 | 88 | observe(fn = noop, config = {childList: true, subtree: true}) { 89 | this.each((ele) => { 90 | let MutationObserver = window.MutationObserver || window.WebKitMutationObserver || window.MozMutationObserver; 91 | let observer = new MutationObserver((mutations) => { 92 | mutations.forEach((mutation) => { 93 | fn.call(this, mutation.target, mutation.addedNodes, mutation.removedNodes); 94 | }); 95 | }); 96 | observer.observe(ele, config); 97 | }); 98 | return this; 99 | }; 100 | 101 | attr(attr, value) { 102 | // one agm 103 | if (arguments.length === 1) { 104 | // get attr value 105 | if (typeof attr === 'string') { 106 | return this[0].getAttribute(attr); 107 | } 108 | // set attr with a json 109 | else if (typeof attr === 'object') { 110 | this.each(function (ele) { 111 | for (let at in attr) { 112 | if (attr.hasOwnProperty(at)) { 113 | ele.setAttribute(at, value); 114 | } 115 | } 116 | }); 117 | return value; 118 | } 119 | } 120 | // set 121 | else if (arguments.length === 2) { 122 | this.each(function (ele) { 123 | ele.setAttribute(attr, value); 124 | }); 125 | return this; 126 | } 127 | else { 128 | return this; 129 | } 130 | }; 131 | 132 | removeAttr(attr) { 133 | if (arguments.length === 1) { 134 | this.each((ele)=> { 135 | ele.removeAttribute(attr); 136 | }); 137 | } 138 | return this; 139 | } 140 | 141 | remove() { 142 | this.each(ele=> { 143 | ele.remove(); 144 | }); 145 | this.length = 0; 146 | return this; 147 | } 148 | 149 | // get the element style 150 | style(attr) { 151 | return this[0].currentStyle ? this[0].currentStyle[attr] : getComputedStyle(this[0])[attr]; 152 | } 153 | 154 | // (attr,value) || 'string' || {} 155 | css(...agm) { 156 | if (agm.length === 1) { 157 | // get style 158 | if (typeof agm[0] === 'string') { 159 | // set style as a long text 160 | if (/:/ig.test(agm[0])) { 161 | this.each(ele=> { 162 | ele.style.cssText = attr; 163 | }); 164 | } 165 | else { 166 | return this[0].currentStyle ? this[0].currentStyle[agm[0]] : getComputedStyle(this[0])[agm[0]]; 167 | } 168 | } 169 | // set style as a object 170 | else { 171 | this.each(ele=> { 172 | for (let attr in agm[0]) { 173 | if (agm[0].hasOwnProperty(attr)) { 174 | ele.style[attr] = agm[0][attr]; 175 | } 176 | } 177 | }); 178 | } 179 | } 180 | // set as (key,value) 181 | else if (agm.length === 2) { 182 | this.each(ele=> { 183 | ele.style[agm[0]] = agm[1]; 184 | }) 185 | } 186 | return this; 187 | } 188 | 189 | width(value) { 190 | let element = this[0]; 191 | // window or document 192 | if (element.window === element || element.body) { 193 | return document.body.scrollWidth > document.documentElement.scrollWidth ? 194 | document.body.scrollWidth : document.documentElement.scrollWidth; 195 | } 196 | // set width 197 | else if (value) { 198 | this.each(ele=> { 199 | ele.style.width = value + 'px'; 200 | }); 201 | return this; 202 | } 203 | // get width 204 | else { 205 | return this[0].offsetWidth || parseFloat(this.style('width')); 206 | } 207 | }; 208 | 209 | height(value) { 210 | let ele = this[0]; 211 | // window or document 212 | if (ele.window === ele || ele.body) { 213 | return document.body.scrollHeight > document.documentElement.scrollHeight ? 214 | document.body.scrollHeight : document.documentElement.scrollHeight; 215 | } 216 | // set height 217 | else if (value) { 218 | this.each(ele=> { 219 | ele.style.height = value + 'px'; 220 | }); 221 | return this; 222 | } 223 | // get height 224 | else { 225 | return this[0].offsetHeight || parseFloat(this.style('height')); 226 | } 227 | } 228 | 229 | html(value) { 230 | if (value !== undefined) { 231 | this.each(ele=> { 232 | ele.innerHTML = typeof value === 'function' ? value(ele) : value; 233 | }); 234 | } else { 235 | return this[0].innerHTML; 236 | } 237 | return this; 238 | } 239 | 240 | text(value) { 241 | if (value === undefined) return this[0].innerText || this[0].textContent; 242 | 243 | this.each(ele=> { 244 | ele.innerText = ele.textContent = value; 245 | }); 246 | return this; 247 | } 248 | 249 | val(value) { 250 | if (value === undefined) return this[0].value; 251 | this.each(ele=> { 252 | ele.value = value; 253 | }); 254 | return this; 255 | } 256 | 257 | show() { 258 | this.each(ele=> { 259 | ele.style.display = ''; 260 | }); 261 | return this; 262 | } 263 | 264 | hide() { 265 | this.each(ele=> { 266 | ele.style.display = 'none'; 267 | }); 268 | return this; 269 | } 270 | 271 | // content str || jqLite Object || DOM 272 | // here is jqLite Object 273 | append(content) { 274 | this.each(ele=> { 275 | ele.appendChild(content[0]); 276 | }); 277 | return this; 278 | }; 279 | 280 | // content str || jqLite Object || DOM 281 | // here is jqLite Object 282 | prepend(content) { 283 | this.each(ele=> { 284 | ele.insertBefore(content[0], ele.children[0]); 285 | }); 286 | return this; 287 | } 288 | 289 | hasClass(className) { 290 | if (!this[0]) return false; 291 | return this[0].classList.contains(className); 292 | } 293 | 294 | addClass(className) { 295 | this.each(ele=> { 296 | ele.classList.add(className); 297 | }); 298 | return this; 299 | } 300 | 301 | removeClass(className) { 302 | this.each(ele=> { 303 | ele.classList.remove(className); 304 | }); 305 | return this; 306 | } 307 | 308 | get index() { 309 | let index = 0; 310 | let brothers = this[0].parentNode.children; 311 | for (let i = 0; i < brothers.length; i++) { 312 | if (brothers[i] == this[0]) { 313 | index = i; 314 | break; 315 | } 316 | } 317 | return index; 318 | } 319 | 320 | static get fn() { 321 | const visible = (ele)=> { 322 | let pos = ele.getBoundingClientRect(); 323 | let w; 324 | let h; 325 | let inViewPort; 326 | let docEle = document.documentElement; 327 | let docBody = document.body; 328 | if (docEle.getBoundingClientRect) { 329 | w = docEle.clientWidth || docBody.clientWidth; 330 | h = docEle.clientHeight || docBody.clientHeight; 331 | inViewPort = pos.top > h || pos.bottom < 0 || pos.left > w || pos.right < 0; 332 | return inViewPort ? false : true; 333 | } 334 | }; 335 | const merge = (...sources) => { 336 | return Object.assign({}, ...sources); 337 | }; 338 | return { 339 | visible, 340 | merge 341 | } 342 | }; 343 | 344 | } 345 | 346 | let $ = (selectors = '', context = document) => { 347 | return new jqLite(selectors, context); 348 | }; 349 | $.fn = jqLite.fn; 350 | 351 | export default $; -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "gm-script", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "index.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "author": "", 10 | "license": "ISC", 11 | "devDependencies": { 12 | "babel": "^6.5.2", 13 | "babel-core": "^6.9.1", 14 | "babel-loader": "^7.0.0", 15 | "babel-preset-es2015": "^6.9.0", 16 | "css-loader": "^0.28.0", 17 | "file-loader": "^0.11.0", 18 | "gulp": "^3.9.1", 19 | "gulp-concat": "^2.6.0", 20 | "gulp-load-plugins": "^1.2.4", 21 | "gulp-webpack": "^1.5.0", 22 | "html-loader": "^0.5.0", 23 | "node-sass": "^4.5.0", 24 | "sass-loader": "^6.0.3", 25 | "style-loader": "^0.19.0", 26 | "svgo": "^0.7.2", 27 | "svgo": "^1.0.0", 28 | "svgo-loader": "^2.0.0" 29 | }, 30 | "dependencies": { 31 | "babel-polyfill": "^6.7.4", 32 | "q": "^1.4.1" 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /scripts/block_posts.js: -------------------------------------------------------------------------------- 1 | import $ from '../libs/jqLite'; 2 | import svg from '../src/block_posts/icon'; 3 | import Panel from '../src/block_posts/panel'; 4 | import common from '../src/block_posts/common'; 5 | 6 | const panel = new Panel(); 7 | const POSITION = common.getPosition(); 8 | 9 | let initCount = 0; 10 | let $icon = $(document.createElement("a")).addClass('block-icon').html(svg); 11 | const init = ()=> { 12 | if (POSITION === 'post') { 13 | initCount++; 14 | $('.p_postlist .l_post').each((post)=> { 15 | let $name = $(post).find('.d_author ul.p_author li.d_name'); 16 | if (!$name[0]) return; 17 | 18 | let id = $name.find('a[data-field].p_author_name').text().trim(); 19 | 20 | if (!id) return; 21 | 22 | let icon = $icon[0].cloneNode(true); 23 | 24 | if (GM_listValues().indexOf(id) > -1) return post.remove(); 25 | 26 | if ($name.find('svg').length) return; 27 | 28 | $(icon).click(()=> { 29 | let [bar,reason] = [common.getBarName(), '在帖子中选择']; 30 | 31 | GM_setValue(id, {id, bar, reason, date: new Date()}); 32 | $('.p_postlist .l_post').each(ele=> { 33 | let username = $(ele).attr('data-field').replace(/\'/g, '"'); 34 | if (!username) return; 35 | username = JSON.parse(username).author.user_name || JSON.parse(username).author.name_u; 36 | username = username.replace(/\&ie\=.*$/ig, ''); 37 | username = decodeURI(username); 38 | if (username === id) ele.remove(); 39 | }); 40 | }); 41 | 42 | $name[0].appendChild(icon); 43 | 44 | }) 45 | } 46 | else if (POSITION === 'list') { 47 | let interval = setInterval(()=> { 48 | let postList = $('ul#thread_list li[data-field].j_thread_list'); 49 | if (!postList.length) return; 50 | 51 | clearInterval(interval); 52 | initCount++; 53 | postList.each(post=> { 54 | let $name = $(post).find('.j_threadlist_li_right .tb_icon_author'); 55 | if (!$name[0]) return; 56 | 57 | let id = $name.find('a[data-field].frs-author-name').text().trim(); 58 | let icon = $icon[0].cloneNode(true); 59 | 60 | if (GM_listValues().indexOf(id) > -1) return post.remove(); 61 | 62 | $(icon).click(()=> { 63 | let [bar,reason] = [common.getBarName(), '贴吧首页选择']; 64 | if (!id) return; 65 | GM_setValue(id, {id, bar, reason, date: new Date()}); 66 | 67 | $('ul#thread_list li[data-field].j_thread_list').each(_post=> { 68 | let username = $(_post).find('a[data-field].frs-author-name').text().trim(); 69 | if (!username) return; 70 | if (username === id) _post.remove(); 71 | }); 72 | 73 | }); 74 | 75 | $name[0].appendChild(icon); 76 | 77 | }) 78 | }, 100); 79 | } 80 | }; 81 | 82 | $(()=> { 83 | 84 | GM_registerMenuCommand("控制面板", panel.create); 85 | GM_addStyle(require("!style!css!sass!./../src/block_posts/style.scss")); 86 | 87 | $(document).bind('keyup', (e)=> { 88 | if (e.keyCode === 120) panel.create(); 89 | }); 90 | 91 | init(); 92 | 93 | $(document).observe((target, addedNodes = [], removedNodes = [])=> { 94 | 95 | addedNodes = Array.from(addedNodes); 96 | 97 | // if (!addedNodes || !addedNodes.length || removedNodes.length) return; 98 | 99 | 100 | addedNodes.forEach((node)=> { 101 | // 翻页 102 | if (node.id === 'content_leftList' || node.id === 'j_p_postlist') { 103 | initCount > 0 && init(); 104 | } 105 | }); 106 | 107 | // 楼中楼翻页 108 | if (target && $(target).hasClass('j_lzl_m_w')) { 109 | 110 | let $lzlList = $(target).find('li.lzl_single_post'); 111 | 112 | $lzlList.each(lzl=> { 113 | let $lzl = $(lzl); 114 | if ($lzl.attr('filter')) return; 115 | 116 | $lzl.attr('filter', true); 117 | let id = JSON.parse($lzl.attr('data-field').replace(/\'/g, '"')).user_name; 118 | id = decodeURI(id); 119 | 120 | if (!id) return; 121 | 122 | if (GM_listValues().indexOf(id) > -1) return lzl.remove(); 123 | 124 | let $name = $lzl.find('.lzl_cnt'); 125 | 126 | if ($name.find('svg').length) return; 127 | 128 | let icon = $icon[0].cloneNode(true); 129 | 130 | $(icon).click(e=> { 131 | let [bar,reason] = [common.getBarName(), '楼中楼选择']; 132 | 133 | GM_setValue(id, {id, bar, reason, date: new Date()}); 134 | 135 | $lzlList.each(_lzl=> { 136 | let username = $(_lzl).find('div.lzl_cnt a.j_user_card').text().trim(); 137 | if (!username) return; 138 | if (username === id) _lzl.remove(); 139 | }); 140 | 141 | }); 142 | $lzl.find('.lzl_content_reply')[0].appendChild(icon); 143 | // $name[0].insertBefore(icon, $name[0].childNodes[0]); 144 | }); 145 | } 146 | 147 | // 148 | let $lzlList = $('ul.j_lzl_m_w'); 149 | if (!$lzlList.length) return; 150 | 151 | $lzlList.each(lzls=> { 152 | if ($(lzls).attr('filter')) return; 153 | 154 | $(lzls).attr('filter', true); 155 | 156 | $(lzls).find('li.lzl_single_post').each(lzl=> { 157 | let $lzl = $(lzl); 158 | let $name = $lzl.find('.lzl_cnt'); 159 | 160 | if ($name.find('svg').length) return; 161 | 162 | let icon = $icon[0].cloneNode(true); 163 | 164 | let id = JSON.parse($lzl.attr('data-field').replace(/\'/g, '"')).user_name; 165 | 166 | if (GM_listValues().indexOf(id) > -1) return lzl.remove(); 167 | 168 | if (!id) return; 169 | 170 | $(icon).click(e=> { 171 | let [bar,reason] = [common.getBarName(), '楼中楼选择']; 172 | GM_setValue(id, {id, bar, reason, date: new Date()}); 173 | // 删除当前楼中楼的 174 | $lzlList.each(_lzl=> { 175 | let $floor = $(_lzl).find('div.lzl_cnt'); 176 | $floor.each(_post=> { 177 | let username = $(_post).find('a.j_user_card').text().trim(); 178 | if (!username) return; 179 | if (username === id) _post.parentElement.remove(); 180 | }); 181 | }); 182 | // 删除帖子里面楼层的 183 | init(); 184 | }); 185 | // $name[0].insertBefore(icon, $name[0].childNodes[0]); 186 | // $name[0].insertBefore(icon, $lzl.find('.lzl_content_reply')); 187 | // $lzl.find('.lzl_content_reply')[0].insertBefore(icon, $lzl.find('.lzl_content_reply')[0].childNodes[1]) 188 | $lzl.find('.lzl_content_reply')[0].appendChild(icon); 189 | }); 190 | }) 191 | 192 | }); 193 | 194 | }); -------------------------------------------------------------------------------- /scripts/meta.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by axetroy on 16-6-4. 3 | */ 4 | 5 | var scripts = [ 6 | { 7 | name: 'block_posts', 8 | title: '贴吧屏蔽某人' 9 | }, 10 | { 11 | name: 'remove_baidu_redirect', 12 | title: '移除baidu搜索的跳转链接' 13 | }, 14 | { 15 | name: 'remove_tieba_ads', 16 | title: '移除贴吧广告' 17 | }, 18 | { 19 | name: 'remove_zhihu_redirect', 20 | title: '移除B乎的跳转链接' 21 | }, 22 | { 23 | name: 'remove_baidu_search_ads', 24 | title: '移除百度搜索置顶推广' 25 | } 26 | ]; 27 | 28 | module.exports = scripts; -------------------------------------------------------------------------------- /scripts/remove_baidu_redirect.js: -------------------------------------------------------------------------------- 1 | import $ from '../libs/jqLite'; 2 | import init from '../src/remove_baidu_redirect/init'; 3 | import observe from '../src/remove_baidu_redirect/observe'; 4 | import mouseover from '../src/remove_baidu_redirect/mouseover'; 5 | import scroll from '../src/remove_baidu_redirect/scroll'; 6 | 7 | $(()=> { 8 | 9 | // init 10 | init(); 11 | 12 | // observe the document 13 | observe(); 14 | 15 | // when mouse over on a A Tag and request 16 | mouseover(); 17 | 18 | // scroll and request 19 | scroll(); 20 | 21 | console.info('去baidu搜索跳转链接启动'); 22 | 23 | }); -------------------------------------------------------------------------------- /scripts/remove_baidu_search_ads.js: -------------------------------------------------------------------------------- 1 | import $ from '../libs/jqLite'; 2 | import $interval from '../libs/$interval'; 3 | import Main from '../src/remove_baidu_search_ads/main'; 4 | 5 | let loop = $interval(()=> { 6 | new Main().filter().turn(); 7 | }, 50); 8 | 9 | // init 10 | $(()=> { 11 | new Main().filter().turn(); 12 | $interval.cancel(loop); 13 | $(document).observe(() => new Main().filter().turn()); 14 | console.info('去广告启动...'); 15 | }); -------------------------------------------------------------------------------- /scripts/remove_tieba_ads.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by axetroy on 16-6-3. 3 | */ 4 | import '../src/remove_tieba_ads/main'; -------------------------------------------------------------------------------- /scripts/remove_zhihu_redirect.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by axetroy on 16-6-4. 3 | */ 4 | 5 | import $ from '../libs/jqLite' 6 | import {$debounce} from '../libs/$debounce'; 7 | import Main from '../src/remove_zhihu_redirect/main'; 8 | 9 | let redirect = `link.zhihu.com/?target=`; 10 | 11 | let config = { 12 | rules: ` 13 | a[href*="${redirect}"] 14 | `.trim().replace(/\n/img, '').replace(/\s{1,}([^a-zA-Z])/g, '$1') 15 | }; 16 | 17 | $(function () { 18 | // init 19 | new Main(config.rules).redirect(); 20 | 21 | $(document).observe($debounce(function (target, addList, removeList) { 22 | if (!addList || !addList.length) return; 23 | new Main(config.rules).redirect(); 24 | }, 200)); 25 | 26 | $(window).bind('scroll', $debounce(function () { 27 | new Main(config.rules).redirect(); 28 | }, 200)); 29 | }); 30 | -------------------------------------------------------------------------------- /src/block_posts/common.js: -------------------------------------------------------------------------------- 1 | 2 | const common = { 3 | // 获取当前所在的位置,是贴吧列表,还是贴吧内容页 4 | getPosition(){ 5 | const url = location.href; 6 | const postInside = /.*tieba.baidu.com\/p\/.*/ig; 7 | const postList = /.*tieba.baidu.com\/(f\?.*|[^p])/ig; 8 | return postInside.test(url) ? 'post' : postList.test(url) ? 'list' : null; 9 | }, 10 | // 获取当前页的贴吧名 11 | getBarName(){ 12 | return $(".card_title_fname").text().trim(); 13 | } 14 | }; 15 | 16 | export default common; 17 | -------------------------------------------------------------------------------- /src/block_posts/formatDate.js: -------------------------------------------------------------------------------- 1 | export default function formatDate(date, fmt) { 2 | var o = { 3 | "M+": date.getMonth() + 1, //月份 4 | "d+": date.getDate(), //日 5 | "h+": date.getHours(), //小时 6 | "m+": date.getMinutes(), //分 7 | "s+": date.getSeconds(), //秒 8 | "q+": Math.floor((date.getMonth() + 3) / 3), //季度 9 | "S": date.getMilliseconds() //毫秒 10 | }; 11 | if (/(y+)/.test(fmt)) fmt = fmt.replace(RegExp.$1, (date.getFullYear() + "").substr(4 - RegExp.$1.length)); 12 | for (var k in o) { 13 | if (new RegExp("(" + k + ")").test(fmt)) { 14 | fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length))); 15 | } 16 | } 17 | return fmt; 18 | }; -------------------------------------------------------------------------------- /src/block_posts/icon.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by axetroy on 5/8/16. 3 | */ 4 | let svg = ` 5 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | `; 15 | 16 | export default svg; -------------------------------------------------------------------------------- /src/block_posts/meta.js: -------------------------------------------------------------------------------- 1 | // ==UserScript== 2 | // @name Block somebody 3 | // @author burningall 4 | // @description 在贴吧屏蔽某人,眼不见心不烦 5 | // @version 2016.6.4 6 | // @include *tieba.baidu.com/p/* 7 | // @include *tieba.baidu.com/* 8 | // @include *tieba.baidu.com/f?* 9 | // @grant GM_addStyle 10 | // @grant GM_getValue 11 | // @grant GM_setValue 12 | // @grant GM_listValues 13 | // @grant GM_deleteValue 14 | // @grant GM_registerMenuCommand 15 | // @run-at document-start 16 | // @compatible chrome 两个字,破费 17 | // @compatible firefox 两个字,破费 18 | // @license The MIT License (MIT); http://opensource.org/licenses/MIT 19 | // @supportURL http://www.burningall.com 20 | // @contributionURL troy450409405@gmail.com|alipay.com 21 | // @namespace https://greasyfork.org/zh-CN/users/3400-axetroy 22 | // ==/UserScript== 23 | 24 | /* 25 | 26 | Github源码:https://github.com/axetroy/GMscript 27 | 28 | */ -------------------------------------------------------------------------------- /src/block_posts/panel.html: -------------------------------------------------------------------------------- 1 |

控制面板

2 |
3 | 4 |
5 | 10 |
11 | 12 |
13 | 14 |
15 |

暂时没什么可配置的...

16 |
17 | 18 |
19 | 20 |
21 |
22 | 25 | 26 |
27 | 28 |
29 | 32 | 33 |
34 | 35 |
36 | 39 | 40 |
41 | 42 | 43 |
44 | 45 |
46 | 47 |
48 |
49 |
50 | 51 |
52 | 53 |
-------------------------------------------------------------------------------- /src/block_posts/panel.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by axetroy on 5/10/16. 3 | */ 4 | 5 | import $ from '../../libs/jqLite'; 6 | import formatDate from './formatDate'; 7 | import common from './common'; 8 | 9 | class Panel { 10 | constructor() { 11 | 12 | } 13 | 14 | create() { 15 | if ($('#block-mask').length) return; 16 | let root = document.createElement('div'); 17 | 18 | this.$mask = $(root.cloneNode(false)).attr('id', 'block-mask'); 19 | this.$panel = $(root.cloneNode(false)) 20 | .attr('id', 'block-panel') 21 | .html(require('./panel.html')); 22 | 23 | this.$mask.append(this.$panel); 24 | 25 | this.$menu = this.$panel.find('.block-menu ul li'); 26 | this.$session = this.$panel.find('.block-content .session'); 27 | this.$config = this.$session.eq(0); 28 | this.$block = this.$session.eq(1); 29 | this.$list = this.$session.eq(2); 30 | 31 | this.init(); 32 | this.link(); 33 | 34 | document.documentElement.appendChild(this.$mask[0]); 35 | return this; 36 | } 37 | 38 | remove() { 39 | this.$mask.remove(); 40 | } 41 | 42 | link() { 43 | let _this = this; 44 | 45 | // 屏蔽列表的点击事件 46 | this.$list.click((e)=> { 47 | let $target = $(e.target); 48 | let index = +$target.attr('list-index'); 49 | let blockID = $target.attr('block-id'); 50 | 51 | this.$list.find('table>tbody>tr').each((ele)=> { 52 | if ($(ele).find('.block-remove').attr('block-id') === blockID) { 53 | ele.remove(); 54 | GM_deleteValue(blockID); 55 | } 56 | }); 57 | 58 | }); 59 | 60 | // 控制面板的切换 61 | this.$menu.click((e)=> { 62 | let index = $(e.target).index; 63 | this.$menu.removeClass('active').eq(index).addClass('active'); 64 | this.$session.hide().eq(index).show(); 65 | return false; 66 | }); 67 | 68 | // 点击屏蔽按钮 69 | // block someone 70 | this.$block.find('.block-block-submit').click(e=> { 71 | 72 | let [$id,$bar,$reason] = ['id', 'bar', 'reason'].map(name=> { 73 | return this.$block.find(`.block-${name}`); 74 | }); 75 | 76 | let [id,bar,reason] = [$id, $bar, $reason].map(input=> { 77 | return input.val(); 78 | }); 79 | 80 | if (!id) return; 81 | GM_setValue(id, {id, bar, reason, date: new Date()}); 82 | $id.val(''); 83 | $reason.val(''); 84 | }); 85 | 86 | // 关掉控制面板 87 | this.$mask.click((e)=> { 88 | if ($(e.target).attr('id') === 'block-mask') this.remove(); 89 | }); 90 | 91 | } 92 | 93 | init() { 94 | this.$menu.eq(0).addClass('active'); 95 | this.$session.hide().eq(0).show(); 96 | this.$panel.find('.block-bar').val(common.getBarName()); 97 | 98 | this.$list.html(()=> { 99 | let GMList = GM_listValues(); 100 | let list = []; 101 | 102 | for (let i = 0; i < GMList.length; i++) { 103 | list[i] = GM_getValue(GMList[i]); 104 | } 105 | 106 | let tableStr = ''; 107 | 108 | list.forEach((v, i)=> { 109 | let time = ''; 110 | if (v.date) { 111 | let date = new Date(v.date); 112 | time = formatDate(date, 'yyyy-MM-dd'); 113 | } 114 | tableStr += ` 115 | 116 | ${v.id} 117 | ${v.bar} 118 | ${v.reason} 119 | ${time} 120 | 121 | 移除 122 | 123 | 124 | `; 125 | }); 126 | 127 | return ` 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | ${tableStr} 140 | 141 |
贴吧ID所在贴吧屏蔽理由屏蔽时间操作
142 | `; 143 | }); 144 | 145 | } 146 | 147 | } 148 | 149 | export default Panel; -------------------------------------------------------------------------------- /src/block_posts/style.scss: -------------------------------------------------------------------------------- 1 | /** 公共部分 **/ 2 | @font-face { 3 | font-family: ifont; 4 | src: url("http://at.alicdn.com/t/font_1442373896_4754455.eot?#iefix") format("embedded-opentype"), url("http://at.alicdn.com/t/font_1442373896_4754455.woff") format("woff"), url("http://at.alicdn.com/t/font_1442373896_4754455.ttf") format("truetype"), url("http://at.alicdn.com/t/font_1442373896_4754455.svg#ifont") format("svg"); 5 | } 6 | 7 | #block-mask { 8 | position: fixed; 9 | top: 0; 10 | left: 0; 11 | z-index: 9999999; 12 | width: 100%; 13 | height: 100%; 14 | background: rgba(45, 45, 45, 0.6); 15 | margin: 0; 16 | padding: 0; 17 | overflow: hidden; 18 | font-size: 14px; 19 | line-height: 1.42857143em; 20 | *{ 21 | -webkit-box-sizing: border-box; 22 | box-sizing: border-box; 23 | } 24 | label { 25 | display: inline-block; 26 | max-width: 100%; 27 | margin-bottom: 5px; 28 | font-weight: 700; 29 | } 30 | .btn{ 31 | display: inline-block; 32 | padding: 6px 12px; 33 | font-size: 14px; 34 | line-height: 1.42857143; 35 | text-align: center; 36 | white-space: nowrap; 37 | vertical-align: middle; 38 | -ms-touch-action: manipulation; 39 | touch-action: manipulation; 40 | cursor: pointer; 41 | -webkit-user-select: none; 42 | -moz-user-select: none; 43 | user-select: none; 44 | background-image: none; 45 | border: 1px solid transparent; 46 | border-radius: 4px; 47 | margin-top: 5px; 48 | margin-bottom: 5px; 49 | color: #333; 50 | background-color: #fff; 51 | border-color: #333; 52 | } 53 | .form-group{ 54 | margin-bottom: 15px; 55 | } 56 | .form-control{ 57 | display: block; 58 | width: 100%; 59 | height: 34px; 60 | padding: 6px 12px; 61 | font-size: 14px; 62 | line-height: 1.42857143; 63 | color: #555; 64 | background-color: #fff; 65 | background-image: none; 66 | border: 1px solid #ccc; 67 | border-radius: 4px; 68 | -webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, .075); 69 | box-shadow: inset 0 1px 1px rgba(0, 0, 0, .075); 70 | -webkit-transition: border-color ease-in-out .15s, -webkit-box-shadow ease-in-out .15s; 71 | transition: border-color ease-in-out .15s, box-shadow ease-in-out .15s; 72 | &:focus{ 73 | border-color: #66afe9; 74 | outline: 0; 75 | -webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, .075), 0 0 8px rgba(102, 175, 233, .6); 76 | box-shadow: inset 0 1px 1px rgba(0, 0, 0, .075), 0 0 8px rgba(102, 175, 233, .6); 77 | } 78 | } 79 | p{ 80 | color: #fff; 81 | line-height: 3em; 82 | } 83 | a{ 84 | color: #555; 85 | text-decoration: none; 86 | } 87 | .block-clear{ 88 | visibility: hidden; 89 | font-size: 0; 90 | width: 0; 91 | height: 0; 92 | clear: both; 93 | } 94 | ul{ 95 | list-style: none; 96 | li{ 97 | color: #555; 98 | } 99 | } 100 | /** 非公共部分 **/ 101 | #block-panel { 102 | position: relative; 103 | top: 100px; 104 | width: 800px; 105 | height: auto; 106 | margin: 0 auto; 107 | background: #fff; 108 | z-index: inherit; 109 | .block-title{ 110 | text-align: center; 111 | line-height: 36px; 112 | font-size: 1.6em; 113 | border-bottom: 1px solid #ccc; 114 | } 115 | .block-container{ 116 | margin-top: 10px; 117 | padding-bottom: 10px; 118 | } 119 | .block-menu{ 120 | width: 10%; 121 | float: left; 122 | ul{ 123 | text-align: center; 124 | li{ 125 | line-height: 4em; 126 | cursor: pointer; 127 | &.active{ 128 | background: #6B6B6B; 129 | color: #fff; 130 | } 131 | } 132 | } 133 | } 134 | .block-content{ 135 | width: 90%; 136 | padding-left: 20px; 137 | float: left; 138 | max-height: 400px; 139 | overflow-y: auto; 140 | .block-list{ 141 | table{ 142 | width: 100%; 143 | tr{ 144 | text-align: center; 145 | line-height: 24px; 146 | } 147 | } 148 | } 149 | } 150 | } 151 | } 152 | 153 | a.block-icon{ 154 | display: inline; 155 | } 156 | 157 | //div.d_author{ 158 | // a.block-icon{ 159 | // visibility: hidden; 160 | // } 161 | // &:hover{ 162 | // a.block-icon{ 163 | // visibility: visible; 164 | // } 165 | // } 166 | //} 167 | //li.j_lzl_s_p{ 168 | // a.block-icon{ 169 | // display: none; 170 | // } 171 | // &:hover{ 172 | // a.block-icon{ 173 | // display: inline; 174 | // } 175 | // } 176 | //} -------------------------------------------------------------------------------- /src/remove_baidu_redirect/config.js: -------------------------------------------------------------------------------- 1 | // config 2 | let CONFIG = { 3 | rules: ` 4 | a[href*="www.baidu.com/link?url"] 5 | :not(.m) 6 | :not([decoding]) 7 | :not([decoded]) 8 | `.trim().replace(/\n/img, '').replace(/\s{1,}([^a-zA-Z])/g, '$1'), 9 | debug: false, 10 | debugStyle: ` 11 | a[decoded]{ 12 | background-color:green !important; 13 | color:#303030 !important; 14 | }; 15 | a[decoding]{ 16 | background-color:yellow !important; 17 | color:#303030 !important; 18 | } 19 | `, 20 | isDecodingAll: false 21 | }; 22 | 23 | export default CONFIG; -------------------------------------------------------------------------------- /src/remove_baidu_redirect/init.js: -------------------------------------------------------------------------------- 1 | import Q from 'q'; 2 | import main from './main'; 3 | import CONFIG from './config'; 4 | 5 | let init = ()=> { 6 | new main(CONFIG.rules).all() 7 | .then(function () { 8 | return Q.resolve(true); 9 | }, function () { 10 | return Q.resolve(true); 11 | }) 12 | .then(function () { 13 | new main(CONFIG.rules).oneByOne(); 14 | }); 15 | }; 16 | 17 | export default init; -------------------------------------------------------------------------------- /src/remove_baidu_redirect/main.js: -------------------------------------------------------------------------------- 1 | import $ from '../../libs/jqLite'; 2 | import Q from 'q'; 3 | import CONFIG from './config'; 4 | import $http from '../../libs/$http'; 5 | 6 | class main { 7 | constructor(agm = '') { 8 | if (!agm) return this; 9 | 10 | this.inViewPort = []; 11 | 12 | $(agm).each(ele => $.fn.visible(ele) && this.inViewPort.push(ele)) 13 | } 14 | 15 | /** 16 | * request a url which has origin links 17 | * @returns {Promise} 18 | */ 19 | all() { 20 | var deferred = Q.defer(); 21 | 22 | let url = window.top.location.href.replace(/(\&)(tn=\w+)(\&)/img, '$1' + 'tn=baidulocal' + '$3'); 23 | 24 | CONFIG.isDecodingAll = true; 25 | 26 | $http.get(url, {timeout: 2000}) 27 | .then(function (response) { 28 | CONFIG.isDecodingAll = false; 29 | 30 | if (!response) return; 31 | let responseText = response.responseText; 32 | 33 | // remove the image/script/css resource 34 | responseText = responseText.replace(/(src=[^>]*|link=[^>])/g, ''); 35 | 36 | let html = document.createElement('html'); 37 | html.innerHTML = responseText; 38 | 39 | $('.t>a:not(.OP_LOG_LINK):not([decoded])').each(sourceEle=> { 40 | $('.f>a', html).each((targetEle) => { 41 | if ($(sourceEle).text().trim() === $(targetEle).text().trim()) { 42 | sourceEle.href = targetEle.href; 43 | $(sourceEle).attr('decoded', true); 44 | } 45 | }); 46 | }); 47 | 48 | deferred.resolve(response); 49 | 50 | }, function (response) { 51 | CONFIG.isDecodingAll = false; 52 | deferred.reject(response); 53 | }); 54 | 55 | return deferred.promise; 56 | } 57 | 58 | one(aEle) { 59 | var deferred = Q.defer(); 60 | 61 | $(aEle).attr('decoding', true); 62 | 63 | $http.head(aEle.href, {timeout: 2000, anonymous: true}) 64 | .then(function (response) { 65 | $(aEle) 66 | .attr('href', response.finalUrl) 67 | .attr('decoded', true) 68 | .removeAttr('decoding'); 69 | deferred.resolve(response); 70 | }, function (response) { 71 | $(aEle).removeAttr('decoding'); 72 | deferred.reject(response); 73 | }); 74 | 75 | return deferred.promise; 76 | } 77 | 78 | /** 79 | * request the A tag's href one by one those in view port 80 | * @returns {main} 81 | */ 82 | oneByOne() { 83 | $(this.inViewPort).each(aEle => { 84 | if (!main.match(aEle)) return; 85 | this.one(aEle); 86 | }); 87 | return this; 88 | } 89 | 90 | /** 91 | * match the Element 92 | */ 93 | static match(ele) { 94 | if (ele.tagName !== "A" 95 | || !ele.href 96 | || !/www\.baidu\.com\/link\?url=/im.test(ele.href) 97 | || !!$(ele).attr('decoded') 98 | || !!$(ele).attr('decoding') 99 | ) { 100 | return false; 101 | } else { 102 | return true; 103 | } 104 | } 105 | 106 | } 107 | 108 | export default main; -------------------------------------------------------------------------------- /src/remove_baidu_redirect/meta.js: -------------------------------------------------------------------------------- 1 | // ==UserScript== 2 | // @name remove the jump link in BAIDU (ECMA6) 3 | // @author axetroy 4 | // @collaborator axetroy 5 | // @description 去除百度搜索跳转链接 6 | // @version 2016.6.6 7 | // @grant GM_xmlhttpRequest 8 | // @include *www.baidu.com* 9 | // @connect * 10 | // @compatible chrome 完美运行 11 | // @compatible firefox 完美运行 12 | // @supportURL http://www.burningall.com 13 | // @run-at document-start 14 | // @contributionURL troy450409405@gmail.com|alipay.com 15 | // @namespace https://greasyfork.org/zh-CN/users/3400-axetroy 16 | // @license The MIT License (MIT); http://opensource.org/licenses/MIT 17 | // ==/UserScript== 18 | 19 | /* 20 | 21 | Github源码:https://github.com/axetroy/GMscript 22 | 23 | */ -------------------------------------------------------------------------------- /src/remove_baidu_redirect/mouseover.js: -------------------------------------------------------------------------------- 1 | // libs 2 | import $ from '../../libs/jqLite'; 3 | import {$debounce} from '../../libs/$debounce'; 4 | import main from './main'; 5 | 6 | let mouseover = ()=> { 7 | $(document).bind('mouseover', $debounce(function (e) { 8 | let aEle = e.target; 9 | if (aEle.tagName !== "A" 10 | || !aEle.href 11 | || !/www\.baidu\.com\/link\?url=/im.test(aEle.href) 12 | || !!$(aEle).attr('decoded') 13 | ) { 14 | return; 15 | } 16 | new main().one(aEle); 17 | }, 100, true)); 18 | }; 19 | 20 | export default mouseover; 21 | -------------------------------------------------------------------------------- /src/remove_baidu_redirect/observe.js: -------------------------------------------------------------------------------- 1 | import $ from '../../libs/jqLite'; 2 | import {$debounce} from '../../libs/$debounce'; 3 | import $addStyle from '../../libs/$addStyle'; 4 | import main from './main'; 5 | import init from './init'; 6 | import CONFIG from './config'; 7 | 8 | let observe = ()=> { 9 | 10 | $(document).observe($debounce(function (target, addList = [], removeList = []) { 11 | if (!addList.length) return; 12 | CONFIG.isDecodingAll ? new main(CONFIG.rules).oneByOne() : init(); 13 | CONFIG.debug && $addStyle(CONFIG.debugStyle); 14 | }, 100)) 15 | 16 | }; 17 | 18 | export default observe; -------------------------------------------------------------------------------- /src/remove_baidu_redirect/scroll.js: -------------------------------------------------------------------------------- 1 | import $ from '../../libs/jqLite'; 2 | import {$debounce} from '../../libs/$debounce'; 3 | import $addStyle from '../../libs/$addStyle'; 4 | import main from './main'; 5 | import CONFIG from './config'; 6 | 7 | let scroll = ()=> { 8 | $(window).bind('scroll', $debounce(function () { 9 | new main(CONFIG.rules).oneByOne(); 10 | CONFIG.debug && $addStyle(CONFIG.debugStyle); 11 | }, 100)); 12 | }; 13 | 14 | export default scroll; -------------------------------------------------------------------------------- /src/remove_baidu_search_ads/config.js: -------------------------------------------------------------------------------- 1 | const CONFIG = { 2 | rules: ` 3 | #content_left>div 4 | :not([class*=result]) 5 | :not([class*=container]) 6 | :not(.leftBlock) 7 | :not(#rs_top_new) 8 | :not([filtered]) 9 | , 10 | #content_left>table 11 | :not(.result) 12 | :not([filtered]) 13 | , 14 | #content_right>table td 15 | div#ec_im_container 16 | , 17 | div.s-news-list-wrapper>div 18 | :not([data-relatewords*="1"]) 19 | , 20 | div.list-wraper dl[data-oad] 21 | :not([data-fb]) 22 | :not([filtered]) 23 | `.trim().replace(/\n/img, '').replace(/\s{1,}([^a-zA-Z])/g, '$1') 24 | }; 25 | 26 | export default CONFIG; -------------------------------------------------------------------------------- /src/remove_baidu_search_ads/main.js: -------------------------------------------------------------------------------- 1 | import $ from '../../libs/jqLite'; 2 | import CONFIG from './config'; 3 | 4 | class Main { 5 | 6 | constructor(rules = CONFIG.rules) { 7 | this.ads = $(rules); 8 | this.length = this.ads.length; 9 | } 10 | 11 | filter() { 12 | this.ads.each((ele, i)=> { 13 | ele.style.cssText = ` 14 | display:none !important; 15 | visibility:hidden !important; 16 | width:0 !important; 17 | height:0 !important; 18 | overflow:hidden !important; 19 | // background-color:red !important; 20 | // border:1px solid red; 21 | `; 22 | ele.setAttribute('filtered', ''); 23 | }); 24 | return this; 25 | } 26 | 27 | turn() { 28 | $('#content_left input[type=checkbox]:not(filtered)').each(function (ele) { 29 | ele.checked = false; 30 | ele.setAttribute('filtered', ''); 31 | }); 32 | return this; 33 | } 34 | 35 | } 36 | 37 | export default Main; -------------------------------------------------------------------------------- /src/remove_baidu_search_ads/meta.js: -------------------------------------------------------------------------------- 1 | // ==UserScript== 2 | // @name 去百度搜索置顶推广 (ECMA6) 3 | // @author axetroy 4 | // @contributor axetroy 5 | // @description 去除插入在百度搜索结果头部、尾部的推广链接。 6 | // @version 2016.6.4 7 | // @grant none 8 | // @include *www.baidu.com* 9 | // @include *zhidao.baidu.com/search* 10 | // @connect * 11 | // @supportURL http://www.burningall.com 12 | // @compatible chrome 完美运行 13 | // @compatible firefox 完美运行 14 | // @run-at document-start 15 | // @contributionURL troy450409405@gmail.com|alipay.com 16 | // @namespace https://greasyfork.org/zh-CN/users/3400-axetroy 17 | // @license The MIT License (MIT); http://opensource.org/licenses/MIT 18 | // ==/UserScript== 19 | 20 | /* 21 | 22 | Github源码:https://github.com/axetroy/GMscript 23 | 24 | */ -------------------------------------------------------------------------------- /src/remove_tieba_ads/config.js: -------------------------------------------------------------------------------- 1 | const CONFIG = { 2 | // 是否是调试模式 3 | debug: false, 4 | adRules: ` 5 | ul#thread_list *[data-daid], 6 | ul#thread_list>li:not([data-field]):not(.thread_top_list_folder) 7 | , 8 | #j_p_postlist *[data-daid], 9 | #j_p_postlist *[data-isautoreply] 10 | , 11 | #thread_list>li 12 | :not([class*="list"]) 13 | :not([data-field]) 14 | , 15 | .p_postlist>div 16 | :not(.p_postlist) 17 | :not([class*="post"]) 18 | :not([data-field]) 19 | , 20 | #aside *[data-daid], 21 | #aside>div[class*="clearfix"], 22 | #aside DIV[id$="ad"], 23 | #aside #encourage_entry, 24 | .my_app,.j_encourage_entry, 25 | .right_section>div.u9_aside, 26 | .right_section>div.clearfix, 27 | .right_section *[data-daid] 28 | , 29 | #pb_adbanner,#pb_adbanner *[data-daid] 30 | , 31 | #com_u9_head, 32 | .u9_head, 33 | div.search_form>div[class*="clearfix"] 34 | , 35 | .firework-wrap 36 | `.trim().replace(/\n/img, '').replace(/\s{1,}([^a-z\*])/ig, '$1'), 37 | keyRules: ` 38 | #j_p_postlist a[data-swapword]:not([filted]), 39 | #j_p_postlist a.ps_cb:not([filted]) 40 | `.trim().replace(/\n/img, '').replace(/\s{1,}([^a-z\*])/ig, '$1') 41 | }; 42 | 43 | export default CONFIG; -------------------------------------------------------------------------------- /src/remove_tieba_ads/main.js: -------------------------------------------------------------------------------- 1 | import $ from '../../libs/jqLite'; 2 | import CONFIG from './config'; 3 | import $interval from '../../libs/$interval'; 4 | import {$debounce} from '../../libs/$debounce'; 5 | 6 | class main { 7 | constructor(agm = '') { 8 | if (!agm) return this; 9 | 10 | this.ads = $(agm); 11 | 12 | } 13 | 14 | filter() { 15 | this.ads.each((ele)=> { 16 | if (ele.$$filtered) return; 17 | ele.style.cssText = CONFIG.debug ? ` 18 | border:2px solid red; 19 | ` : ` 20 | display:none !important; 21 | visibility:hidden !important; 22 | width:0 !important; 23 | height:0 !important; 24 | overflow:hidden !important; 25 | `; 26 | ele.$$filtered = true; 27 | }); 28 | return this; 29 | } 30 | 31 | keyword() { 32 | $(CONFIG.keyRules).each(function (aEle) { 33 | if (aEle.$$filtered) return; 34 | aEle.removeAttribute('data-swapword'); 35 | aEle.removeAttribute('class'); 36 | aEle.removeAttribute('href'); 37 | aEle.style.cssText = CONFIG.debug ? ` 38 | color:#fff !important; 39 | background-color:red !important; 40 | ` : ` 41 | color:inherit !important; 42 | `; 43 | aEle.$$filtered = true; 44 | }); 45 | return this; 46 | } 47 | 48 | } 49 | 50 | let loop = $interval(()=> { 51 | new main(CONFIG.adRules).filter().keyword(); 52 | }, 50); 53 | 54 | console.info('贴吧去广告启动...'); 55 | 56 | $(document).bind('DOMContentLoaded', ()=> { 57 | 58 | $interval.cancel(loop); 59 | 60 | // init 61 | new main(CONFIG.adRules).filter().keyword(); 62 | 63 | $(document).observe($debounce(function (target, addList, removeList) { 64 | if (!addList || !addList.length) return; 65 | new main(CONFIG.adRules).filter().keyword(); 66 | }, 200)); 67 | 68 | $(window).bind('scroll', $debounce(function () { 69 | new main(CONFIG.adRules).filter().keyword(); 70 | }, 200)); 71 | 72 | }); -------------------------------------------------------------------------------- /src/remove_tieba_ads/meta.js: -------------------------------------------------------------------------------- 1 | // ==UserScript== 2 | // @name 去除贴吧列表里面的广告 3 | // @author axetroy 4 | // @description 去除贴吧掺夹在[帖子列表][回复列表]里的广告 5 | // @version 2016.6.4 6 | // @include http://tieba.baidu.com/* 7 | // @connect tags 8 | // @connect * 9 | // @compatible chrome 完美运行 10 | // @compatible firefox 完美运行 11 | // @supportURL http://www.burningall.com 12 | // @run-at document-start 13 | // @contributionURL troy450409405@gmail.com|alipay.com 14 | // @namespace https://greasyfork.org/zh-CN/users/3400-axetroy 15 | // @license The MIT License (MIT); http://opensource.org/licenses/MIT 16 | // ==/UserScript== 17 | 18 | /* 19 | 20 | Github源码:https://github.com/axetroy/GMscript 21 | 22 | */ -------------------------------------------------------------------------------- /src/remove_zhihu_redirect/main.js: -------------------------------------------------------------------------------- 1 | import $ from '../../libs/jqLite'; 2 | 3 | class Main { 4 | constructor(agm = '') { 5 | if (!agm) return this; 6 | this.inViewPort = []; 7 | 8 | $(agm).each((aEle) => { 9 | if ($.fn.visible(aEle)) this.inViewPort.push(aEle); 10 | }); 11 | } 12 | 13 | redirect() { 14 | $(this.inViewPort).each(function (aEle) { 15 | if (!aEle || !aEle.href) return; 16 | let href = aEle.href.trim().replace(/^.*link\.zhihu\.com\/\?target=(.*?)$/im, '$1') 17 | .trim().replace(/^\s*http[^\/]*\/\//, 'http://'); 18 | href = decodeURIComponent(href); 19 | aEle.href = href; 20 | }); 21 | return this; 22 | } 23 | 24 | } 25 | 26 | export default Main -------------------------------------------------------------------------------- /src/remove_zhihu_redirect/meta.js: -------------------------------------------------------------------------------- 1 | // ==UserScript== 2 | // @name 去除知乎跳转 3 | // @author axetroy 4 | // @description 去除知乎重定向,不再跳转 5 | // @version 2016.6.6.1 6 | // @include *www.zhihu.com* 7 | // @include *zhuanlan.zhihu.com* 8 | // @connect tags 9 | // @connect * 10 | // @compatible chrome 完美运行 11 | // @compatible firefox 完美运行 12 | // @supportURL http://www.burningall.com 13 | // @run-at document-start 14 | // @contributionURL troy450409405@gmail.com|alipay.com 15 | // @namespace https://greasyfork.org/zh-CN/users/3400-axetroy 16 | // @license The MIT License (MIT); http://opensource.org/licenses/MIT 17 | // ==/UserScript== 18 | 19 | /* 20 | 21 | Github源码:https://github.com/axetroy/GMscript 22 | 23 | */ -------------------------------------------------------------------------------- /webpack.config.js: -------------------------------------------------------------------------------- 1 | var webpack = require('webpack'); 2 | var path = require('path'); 3 | var scripts = require('./scripts/meta'); 4 | 5 | // webpack.config.js 6 | module.exports = { 7 | entry: (function () { 8 | let obj = {}; 9 | scripts.forEach(v=> obj[v.name] = path.join(__dirname, 'scripts', v.name)); 10 | return obj; 11 | })(), 12 | output: { 13 | filename: '[name].js' 14 | }, 15 | resolve: { 16 | extensions: ['', '.coffee', '.js'] 17 | }, 18 | module: { 19 | loaders: [ 20 | { 21 | test: /\.(jsx|js)?$/, 22 | exclude: /(node_modules|bower_components)/, 23 | loader: 'babel', 24 | query: { 25 | presets: ['es2015'], 26 | plugins: [] 27 | } 28 | }, 29 | { 30 | test: /\.html$/, 31 | loader: "html" 32 | }, 33 | { 34 | test: /.*\.svg$/, 35 | loaders: [ 36 | 'file-loader', 37 | 'svgo-loader?useConfig=svgoConfig1' 38 | ] 39 | } 40 | ] 41 | }, 42 | svgoConfig1: { 43 | plugins: [ 44 | {removeTitle: true}, 45 | {convertColors: {shorthex: false}}, 46 | {convertPathData: false} 47 | ] 48 | }, 49 | plugins: [ 50 | //js文件的压缩 51 | // new webpack.optimize.UglifyJsPlugin({ 52 | // compress: { 53 | // warnings: false 54 | // }, 55 | // mangle: { 56 | // except: ['$super', '$', 'exports', 'require'] 57 | // } 58 | // }), 59 | ] 60 | }; --------------------------------------------------------------------------------