Skip to content

Instantly share code, notes, and snippets.

@kuy
Created February 24, 2015 04:32
Show Gist options
  • Save kuy/9baf2e511375ac3ab43f to your computer and use it in GitHub Desktop.
Save kuy/9baf2e511375ac3ab43f to your computer and use it in GitHub Desktop.
Qiita Tag Search Enhancer: Provide a way to search by multiple tags easily.
// ==UserScript==
// @name Qiita Tag Search Enhancer
// @namespace http://endflow.net/
// @version 0.2.0
// @description Provide a way to search by multiple tags easily.
// @author Yuki Kodama <[email protected]>
// @match http://qiita.com/*
// ==/UserScript==
$('.itemsShowHeaderTags .itemsShowHeaderTags_list')
.each(function(){
var tag = $(this).find('.tagIcon_name').text();
$(this).prepend($('<input type="checkbox" style="margin-right: 8px" data-keyword="tag:' + tag + '"></input>'));
});
var author = $('.itemsShowAuthorInfo .itemsShowAuthorInfo_userName').text();
$('.itemsShowHeaderTags')
.append($('<a href="#" type="button" value="Search" class="btn btn-warning btn-xs qtse disabled">Search</a>'))
.append($('<label class="checkbox-inline" style="margin-left: 8px"><input type="checkbox" data-keyword="user:' + author + '" />Filter by author</label>'))
.on('change', 'input[type="checkbox"]', function(){
var keywords = $('.itemsShowHeaderTags input:checked').map(function(){return $(this).data('keyword')}).get();
$('.itemsShowHeaderTags .btn.qtse')
.attr('href', '/search?' + $.param({ q: keywords.join(' ') }))
.toggleClass('disabled', keywords.length == 0);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment