Skip to content

Instantly share code, notes, and snippets.

@dhigginbotham
Last active September 1, 2015 02:31
Show Gist options
  • Save dhigginbotham/201557aae88193eec9f2 to your computer and use it in GitHub Desktop.
Save dhigginbotham/201557aae88193eec9f2 to your computer and use it in GitHub Desktop.
var youTuber = (function(w,d,pub) {
var priv = {};
var state = {};
state.links = {};
priv.findLinksInElem = function(elem) {
var cur = {};
cur.href = elem.getAttribute('href');
cur.sessionlink = elem.getAttribute('data-sessionlink');
cur.title = elem.getAttribute('title');
if (cur.href && cur.sessionlink && cur.title) {
if (cur.href.indexOf('/watch?') != -1) {
state.links[cur.title] = cur;
}
}
};
priv.collectElems = function() {
state.dom = d.getElementsByTagName('a');
Array.prototype.map.call(state.dom, priv.findLinksInElem);
console.log(state.links); // wee@
};
priv.init = function() {
priv.collectElems();
pub.state = state;
};
priv.init();
return pub;
})(window,document,{});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment