Created
April 15, 2009 17:10
-
-
Save tghw/95907 to your computer and use it in GitHub Desktop.
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 Remove Answered Questions | |
// @namespace tghw | |
// @include http://stackoverflow.com/ | |
// @include http://stackoverflow.com/questions/* | |
// ==/UserScript== | |
var GM_JQ = document.createElement('script'); | |
GM_JQ.src = 'http://jquery.com/src/jquery-latest.js'; | |
GM_JQ.type = 'text/javascript'; | |
document.getElementsByTagName('head')[0].appendChild(GM_JQ); | |
// Check if jQuery's loaded | |
function GM_wait() { | |
if(typeof unsafeWindow.jQuery == 'undefined') { window.setTimeout(GM_wait,100); } | |
else { $ = unsafeWindow.jQuery; inject_others(); main(); } | |
} | |
function inject_others() | |
{ | |
$('<SCRIPT>').attr({src: 'http://plugins.jquery.com/files/jquery.cookie.js.txt', type: 'text/javascript'}).appendTo('head'); | |
} | |
GM_wait(); | |
function main() | |
{ | |
var a = $('<a>'); | |
a.text('Hide Answered Questions'); | |
a.css({float: 'left', lineHeight: '36px', marginLeft: 10}); | |
a.attr({id: 'aHide', href: '#'}); | |
a.click(hide_answered) | |
a.insertAfter('#subheader h2'); | |
if($.cookie('hide_answered') == '1') | |
{ | |
hide_answered(); | |
} | |
} | |
function hide_answered() | |
{ | |
$('.answered-accepted').each(function(){$(this).parents('.question-summary').hide();}); | |
$.cookie('hide_answered', '1'); | |
$('#aHide').unbind('click', hide_answered).click(show_answered).text('Show Answered Questions'); | |
} | |
function show_answered() | |
{ | |
$('.answered-accepted').each(function(){$(this).parents('.question-summary').show();}); | |
$.cookie('hide_answered', '0'); | |
$('#aHide').unbind('click', show_answered).click(hide_answered).text('Hide Answered Questions'); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment