Last active
May 6, 2016 19:29
-
-
Save WillSullivan/5949248 to your computer and use it in GitHub Desktop.
This userscript will add a list (initially hidden in an expandable div) containing links to every question listed on a tag page (i.e., questions/tagged/something). When a link in this list is clicked, it goes away. This allows you to easily open up many questions with this tag at the same time. Simply ctrl-click on the first link, then keep clic…
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
// ==UserScript== | |
// @name Tag list | |
// @namespace http://statestreetgang.net/ | |
// @version 1.1 | |
// @description Adds an expandable list containing a link to every question on the current tag page. Useful when you want to open many questions with the same tag at the same time. | |
// @match http://stackoverflow.com/*tag*/* | |
// @match http://meta.stackoverflow.com/*tag*/* | |
// ==/UserScript== | |
function exec(fn) { | |
var script = document.createElement('script'); | |
script.setAttribute("type", "application/javascript"); | |
script.textContent = '(' + fn + ')();'; | |
document.body.appendChild(script); // run the script | |
document.body.removeChild(script); // clean up | |
} | |
window.addEventListener("load", function () { | |
// script injection | |
exec(function () { | |
// move all the already handled shit to the top | |
$.each(["closed", "on hold", "migrated", "duplicate",], function (index) | |
{ | |
var items = $('a:contains(' + this + ')'); | |
items.closest('.question-summary').detach().appendTo('#questions'); | |
}); | |
// get all the hrefs | |
var root = $('#questions'); | |
var hrefs = root.find('.question-hyperlink'); | |
if (hrefs.length === 0) | |
return; | |
// I totally copypasted this. | |
$('head').append($('<style type="text/css">.linkylist {margin: 0px;padding: 0px;}.linkyhead {padding: 5px 10px;cursor: pointer;position: relative;background-color:#FFCCCC;margin:1px;} .linkybody {padding: 5px 10px 15px;background-color:#F4F4F8;}</style>')); | |
var listroot = $('<div class="linkylist"/>'); | |
var listhead = $('<p class="linkyhead">Click here to open a list of all links on this page</p>'); | |
var listbody = $('<div class="linkybody"/>'); | |
$('.question').before(listroot); | |
listroot.prepend(listbody); | |
listroot.prepend(listhead); | |
listbody.hide(); | |
listhead.click(function (){ listbody.slideToggle(600); }); | |
// note that when you click a link it gets removed from the list. | |
hrefs.each(function () | |
{ | |
var parent = $('<span class="linkeyspan"/>'); | |
var linkey = $(this).clone(); | |
linkey.click(function () { $(this).closest('.linkeyspan').remove(); }); | |
parent.prepend(linkey); | |
parent.prepend($('<br/>')); | |
listbody.prepend(parent); | |
}); | |
}); | |
}, false); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Will, turns out there are no pull requests on GitHub. Anyway, I have updated this user script so that it works with the redesigned user experience on Stack sites. There are some additional tweaks as well.
Known Problems:
Take my Latest Revision.
Cheers!
PS: I changed the name to TaggedQuestionList.user.js to facilitate automatic updates.