Last active
December 12, 2015 03:28
-
-
Save petsel/4706900 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function () { | |
var | |
global = this, | |
ArrProto = global.Array.prototype, | |
proto_slice = ArrProto.slice, | |
proto_map = ArrProto.map, | |
proto_reduce = ArrProto.reduce, | |
object_keys = global.Object.keys, | |
doc = global.document, | |
idList = proto_map.call( | |
doc.querySelectorAll("[id]"), | |
function (elm) { | |
return elm.id; | |
} | |
).sort(), | |
classNameList = object_keys(proto_reduce.call( | |
doc.querySelectorAll("[class]"), | |
function (collector, elm) { | |
return collector.concat(proto_slice.call(elm.classList)); | |
}, []).reduce(function (collector, className) { | |
return ((collector[className] = 1) && collector); | |
}, {}) | |
).sort() | |
; | |
return { | |
"idList" : idList, | |
"idStream" : idList.join(", "), | |
"classNameList" : classNameList, | |
"classNameStream" : classNameList.join(", ") | |
}; | |
}).call(null); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function(){var a=this.Array.prototype,d=a.slice,b=a.reduce,e=this.Object.keys,c=this.document,a=a.map.call(c.querySelectorAll("[id]"),function(a){return a.id}).sort(),b=e(b.call(c.querySelectorAll("[class]"),function(a,b){return a.concat(d.call(b.classList))},[]).reduce(function(a,b){return(a[b]=1)&&a},{})).sort();return{idList:a,idStream:a.join(", "),classNameList:b,classNameStream:b.join(", ")}}).call(null); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment