Skip to content

Instantly share code, notes, and snippets.

@xiangzhuyuan
Created December 14, 2019 00:35
Show Gist options
  • Save xiangzhuyuan/a278a313252f9b6716092a63b5c601aa to your computer and use it in GitHub Desktop.
Save xiangzhuyuan/a278a313252f9b6716092a63b5c601aa to your computer and use it in GitHub Desktop.
tempermonkey script to help easy filter aj club event
// ==UserScript==
// @name filter event by aj club name
// @namespace http://tampermonkey.net/
// @version 0.1
// @require http://code.jquery.com/jquery-3.3.1.min.js
// @description add a club index in the head then you could get by event list by club!
// @author Matt
// @match https://www.audax-japan.org/*
// @grant none
// ==/UserScript==
(function() {
'use strict';
function onlyUnique(value, index, self) {
return self.indexOf(value) === index;
};
function onlyShowme(event){
$("table > tbody > tr").each(function(){
$(this).show();
if($(this).find("td:nth-child(3)").text() !== event.target.text)
{
$(this).hide();
}
});
};
var club_list = [];
var only_unique=[];
$("table > tbody > tr > td:nth-child(3)").each(function(){
club_list.push($(this).text());
only_unique = club_list.filter(onlyUnique).filter(function(e) { return e !== '' }).filter(function(e) { return e !== '主催' });
});
for(var i = 0; i < only_unique.length; i++) {
$("#post-21795 > div").prepend("<a id='"+ only_unique[i] +"' style='padding:3px;cursor: context-menu;'>"+ only_unique[i] +"</a>");
};
for(var j = 0; j < only_unique.length; j++) {
$("#"+ only_unique[j]).click(onlyShowme);
};
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment