Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ==UserScript==
- // @name Reddit Bookmarklets for Comments
- // @description Add bookmarklets next to "sorted by:" on the comment pages.
- // @version 1.0
- // @date 2010.03.10
- // @include http://*.reddit.com/r/*/comments/*
- // @include http://reddit.com/r/*/comments/*
- // ==/UserScript==
- (function() {
- var bookmarklets = new Array()
- bookmarklets[0] = "javascript:%20function%20show_images(find_string,%20gonewild){var%20gonewild%20=%20gonewild%20||%20'';var%20x=%20$(\".content\").find(find_string).each(function(){var%20re%20=%20new%20RegExp(\"[^a-zA-Z]\"+gonewild+\"[^a-zA-Z]\",\"i\");var%20href=$(this).attr(\"href\");var%20title_text=$(this).text();if((!$(this).hasClass(\"drowsapMorphed\"))%20&&%20($(this).next(\".drowsapMorphed\").length==0)%20&&%20href%20&&%20(gonewild%20==''%20||%20title_text.match(re))%20&&(href.indexOf('imgur.')>=0%20||%20href.indexOf('.jpeg')>=0%20||%20href.indexOf('.jpg')>=0%20||%20href.indexOf('.gif')>=0)){var%20ext%20=(href.indexOf('imgur.')>=0%20&&%20href.indexOf('.jpg')<0%20&&%20href.indexOf('.png')<0%20&&%20href.indexOf('.gif')<0)%20?%20'.jpg'%20:'';%20var%20img%20=%20$(\"<a%20class='drowsapMorphed'%20href='\"+href+\"'%20onclick='window.open(this.href);return%20false;'%20style='display:block'><img%20style='display:block;max-width:720px;'%20src='\"+href+%20ext+\"'%20/></a>\");$(this).after(img);}});};%20show_images(\"#siteTable%20div.entry%20p.title%20a.title\");show_images(\".usertext-body%20a\");";
- bookmarklets[1] =
- "javascript: var%20depth%20= 0;(function%20toggle_children()%20{$(document).find(\".comment%20.child%20.entry%20.collapsed%20.expand\").click();$(document).find(\".comment%20\"%20+%20Array(depth+1).join(\".child \")%20+%20\".entry%20.noncollapsed%20.expand\").click();})()";
- bookmarklets[2] =
- "javascript: var%20depth%20= 1;(function%20toggle_children()%20{$(document).find(\".comment%20.child%20.entry%20.collapsed%20.expand\").click();$(document).find(\".comment%20\"%20+%20Array(depth+1).join(\".child \")%20+%20\".entry%20.noncollapsed%20.expand\").click();})()";
- bookmarklets[3] =
- "javascript: var%20depth%20= 2;(function%20toggle_children()%20{$(document).find(\".comment%20.child%20.entry%20.collapsed%20.expand\").click();$(document).find(\".comment%20\"%20+%20Array(depth+1).join(\".child \")%20+%20\".entry%20.noncollapsed%20.expand\").click();})()";
- bookmarklets[4] =
- "javascript: var%20depth%20= 3;(function%20toggle_children()%20{$(document).find(\".comment%20.child%20.entry%20.collapsed%20.expand\").click();$(document).find(\".comment%20\"%20+%20Array(depth+1).join(\".child \")%20+%20\".entry%20.noncollapsed%20.expand\").click();})()";
- var titles = new Array()
- titles[0] = "View Images";
- titles[1] = "0"
- titles[2] = "1";
- titles[3] = "2";
- titles[4] = "3";
- var menu = document.getElementsByClassName('menuarea')[0];
- for (var i = 0; i < bookmarklets.length; i++) {
- var div = document.createElement('div');
- var a = document.createElement('a');
- var text = document.createTextNode("[ "+titles[i]+" ]");
- a.setAttribute('href',bookmarklets[i]);
- a.appendChild(text);
- div.appendChild(a);
- div.className = "spacer";
- menu.appendChild(div);
- }
- })();
Add Comment
Please, Sign In to add comment