/
hnCW.js
50 lines (44 loc) · 1.72 KB
/
hnCW.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
/*
Welcome to a Hacker News Bookmarklet...
"hnCommentWatcher" by cChristopher de Beer
v1.1
jQuery Bookmarklet loader/initialiser
*/
// Loadem Up!
(function(opts){fullFunc(opts)})({
css: [
hncBase + "hnCommentWatcher.css"
],
js : [
hncBase + "lib/hnutimer.js",
hncBase + "lib/jquery.scrollTo.js",
hncBase + "lib/jenkinsHash.js",
hncBase + "lib/underscore-1.2.3.min.js",
hncBase + "hnCommentWatcher.js"
],
ready : function() {
// Only works on the main page
// var loc = window.document.location;
// if(loc.hostname !== "news.ycombinator.com" || loc.pathname !== "/item" ){
// alert("Only works on Hacker News item/post page:\nhttp://news.ycombinator.com/item");
// return;
// };
// Start the show.
init();
hnutimer.init(function(){loop();})
// Open all links in a new tab.
// ... I don't usually like to do such a thing, but by public demand...
$("body a").live("click", function(){
$(this).attr("target", "_blank");
});
}
});
// jQuery bookmarklet magic...
// ... by Brett Barros (& Paul Irish)
// ... http://www.latentmotion.com/downloads/blank-bookmarklet-v1.js
function fullFunc(a){function d(b){if(b.length===0){a.ready();return false}
$.getScript(b[0],function(){d(b.slice(1))})}function e(b){$.each(b,function(c,f){$("<link>")
.attr({href:f,rel:"stylesheet",type:'text/css'}).appendTo("head")})}a.jqpath=a.
jqpath||"http://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js";
(function(b){var c=document.createElement("script");c.type="text/javascript";c.src=b;
c.onload=function(){e(a.css);d(a.js)};document.body.appendChild(c)})(a.jqpath)};