- 核心是 matchSelector 方法,可以借用了 jQuery.fn.is 方法;
- 选择器匹配了多个元素时,事件触发顺序应该从底向上;
- 绑定多个监听函数时并多时匹配到多个元素时,依次发生顺序要正确;
- 匹配目标应该包含 event.target,不包含委托的顶层元素;
- 反注册时,清理代理函数;
JSON.stringify(delegateMap, function(k, v) {
return typeof v === 'function' ? 'fn' : v
}, ' ')| // ==UserScript== | |
| // @name nospm | |
| // @version 1.6.3 | |
| // @run-at document-start | |
| // @updateURL https://gist.github.com/ambar/9706385/raw/nospm.user.js | |
| // @downloadURL https://gist.github.com/ambar/9706385/raw/nospm.user.js | |
| // @description 移除 Bilibili、淘宝、天猫、优酷等网址中的 spm 参数(包括地址栏和页面中的链接) | |
| // @include https://*.bilibili.com/* | |
| // @include https://*.taobao.com/* | |
| // @include https://*.tmall.com/* |
| @font-face { | |
| font-family: 'Helvetica Neue'; | |
| unicode-range: U+0600—06FF, U+0750—077F, U+08A0—08FF, U+FB50—FDFF, U+FE70—FEFF, U+10E60—10E7F, U+1EE00—1EEFF; | |
| src: local(Arial); | |
| } | |
| @font-face { | |
| font-family: 'Helvetica Neue'; | |
| font-weight: bold; | |
| unicode-range: U+0600—06FF, U+0750—077F, U+08A0—08FF, U+FB50—FDFF, U+FE70—FEFF, U+10E60—10E7F, U+1EE00—1EEFF; | |
| src: local(Arial); |
| var exports = // | |
| exports.protocal = 'zhihu://' | |
| exports.applink = 'http://itunes.apple.com/cn/app/id432274380' | |
| /** | |
| * 尝试在 zhihu iPhone App 中打开链接 | |
| * @param {string} url | |
| */ |
| var makePile = function(count, onfilter, onvalue) { | |
| var values = [] | |
| var id = function(value) { | |
| // console.info('onvalue::', value) | |
| return value | |
| } | |
| return function(value) { | |
| values.push((onvalue || id).apply(this, arguments)) | |
| if (values.length === count) { | |
| onfilter.apply(this, values) |
| // ==UserScript== | |
| // @name sans-serif enabler | |
| // @include http://www.zhihu.com/* | |
| // ==/UserScript== | |
| document.head.querySelector('link[href$="punctuation.css"]').disabled = true |
| var autorestore_ = function(element) { | |
| var oldPosition = element.getBoundingClientRect().bottom | |
| setTimeout(function() { | |
| var newPosition = element.getBoundingClientRect().bottom | |
| window.scrollTo(window.scrollX, window.scrollY + newPosition - oldPosition) | |
| }) | |
| } |
| .tooltip { | |
| position: absolute; | |
| z-index: 1050; | |
| .animated(); | |
| .animation-duration(.55s); | |
| .animation-timing-function(ease-in); | |
| &.in { | |
| // .fadeInDown(); | |
| .lightSpeedIn(); | |
| // .rollIn(); |
| $ git branch -r --merged | | |
| grep origin | | |
| grep -v '>' | | |
| grep -v master | | |
| xargs -L1 | | |
| awk '{split($0,a,"/"); { if (a[3]) { print a[2]"/"a[3] } else { print a[2] } }}' | | |
| xargs git push origin --delete |
JSON.stringify(delegateMap, function(k, v) {
return typeof v === 'function' ? 'fn' : v
}, ' ')| /** | |
| * @author ambar | |
| * @ref http://en.wikipedia.org/wiki/VCard | |
| */ | |
| function parse(csv, sep) { | |
| sep = sep || ',' | |
| var lines = csv.split('\n'), head = lines.shift().split(sep) | |
| var json = lines.map(function(line) { | |
| var person = {}, values = line.split(sep) |