Skip to content

Instantly share code, notes, and snippets.

@Tiny-Giant
Forked from mogsdad/TaggedQuestionList.user.js
Last active September 26, 2015 19:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Tiny-Giant/1e1f62f83d60514dfe97 to your computer and use it in GitHub Desktop.
Save Tiny-Giant/1e1f62f83d60514dfe97 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…
// ==UserScript==
// @name Tag list
// @namespace http://stackapps.com/questions/4207/burninator-toolkit
// @author Will Sullivan (Will)
// @developer David Bingham (Mogsdad)
// @version 1.2.6
// @grant none
// @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.
// @include /^https?://(meta\.)?(stackoverflow|stackexchange|serverfault|superuser|askubuntu|stackapps)\.com/(questions/(new|popular|need-answers)|search).*/
// ==/UserScript==
TagList();
$(document).ajaxComplete(TagList);
function TagList() {
"use strict";
if($('.linkylist').length) return;
var App = {};
// Locate the element containing list of posts.
App.linkytarget = $('.question-summary').parent();
//console.log(App.linkytarget);
// re-sort list; move all the already handled cruff to the top
$.each(["closed", "on hold", "migrated", "duplicate"], function(index) {
App.items = $('.question-summary .summary:contains(' + this + ')');
App.items.closest('.question-summary').detach().appendTo(App.linkytarget);
});
// get all the hrefs
App.root = App.linkytarget;
App.hrefs = App.root.find('.question-hyperlink,.result-link'); // .result-link on searches, .question-hyperlink everywhere else
if (App.hrefs.length === 0) {
console.log("No post hyperlinks found");
return;
}
App.listroot = $('<div class="linkylist"/>');
App.listhead = $('<p class="linkyhead">Click here to <span id="linkyaction">open</span> a list of all links on this page</p>');
App.listbody = $('<div class="linkybody"/>');
App.linkytarget.before(App.listroot);
App.listroot.prepend(App.listbody);
App.listroot.prepend(App.listhead);
App.listbody.hide();
App.listhead.click(function() {
App.listbody.slideToggle(600);
$('#linkyaction').text(function (index, text) {
return (text == 'open' ? 'close' : 'open');
});
});
// note that when you click a link it gets removed from the list.
App.hrefs.each(function() {
App.parent = $('<span class="linkeyspan"/>');
App.linkey = $(this).clone().attr('target', '_blank');
App.linkey.click(function() {
$(this).closest('.linkeyspan').remove();
});
App.parent.prepend(App.linkey);
App.parent.prepend($('<br/>'));
App.listbody.prepend(App.parent);
});
$('body').append(
$('<style>' +
'.linkylist {margin: 0px;padding: 0px;}' +
'.linkyhead {text-align: right;padding: 5px 10px;cursor: pointer;position: relative;background-color:#FFCCCC;margin:1px;}' +
'.linkybody {padding: 5px 10px 15px;background-color:#F4F4F8;}' +
'</style>')
);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment