Skip to content

Instantly share code, notes, and snippets.

@unarist
Last active June 17, 2016 13: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 unarist/6e4e55a1fafec9942024 to your computer and use it in GitHub Desktop.
Save unarist/6e4e55a1fafec9942024 to your computer and use it in GitHub Desktop.
pso2swiki 検索結果のコメント系を折りたたむ
// ==UserScript==
// @name pso2swiki 検索結果のコメント系を折りたたむ
// @namespace https://github.com/unarist/
// @updateURL https://gist.github.com/unarist/6e4e55a1fafec9942024/raw
// @version 0.2
// @author unarist
// @match http://pso2.swiki.jp/?*&cmd=search&*
// @match http://pso2m.swiki.jp/?*&cmd=search&*
// @grant none
// ==/UserScript==
var $root = $('#body ul');
var $commentPages = $root.find('a[href*=Comments]').parent();
// ついでに日付でソート
$commentPages = $commentPages.map((i,e) => ({e:e, d: $(e).text().match(/\((\d+)d\)/)[1]})).sort((a,b) => a.d - b.d).map((i,x) => x.e);
var $li = $('<li>');
$('<a style="cursor:pointer">▼Comments</a>')
.click(function(){ $('#commentLinks').toggle(); })
.appendTo($li);
$('<ul id="commentLinks" style="display: none">')
.append($commentPages)
.appendTo($li);
$li.prependTo($root);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment