Skip to content

Instantly share code, notes, and snippets.

@sue445
Created March 31, 2012 09:04
Show Gist options
  • Save sue445/2261056 to your computer and use it in GitHub Desktop.
Save sue445/2261056 to your computer and use it in GitHub Desktop.
add total count group by mark to chouseisan
// ==UserScript==
// @name chouseisan
// @namespace net.sue445
// @description 調整さんに人数集計を追加します
// @include http://chouseisan.com/schedule/List*
// ==/UserScript==
(function(d, func) {
var check = function() {
if (typeof unsafeWindow.jQuery == 'undefined') return false;
func(unsafeWindow.jQuery); return true;
}
if (check()) return;
var s = d.createElement('script');
s.type = 'text/javascript';
s.src = 'https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js';
d.getElementsByTagName('head')[0].appendChild(s);
(function() {
if (check()) return;
setTimeout(arguments.callee, 100);
})();
})(document, function($) {
// thx) http://www.otchy.net/20091104/use-jquery-on-greasemonkey/
var td_attrs = {
"valign":"top",
"style":"border-bottom:1px solid #ddd"
};
$("#nittei tr:first").append( $("<td/>").attr(td_attrs).text("○+△") );
$("#nittei tr:first").append( $("<td/>").attr(td_attrs).text("○") );
$("#nittei tr:first").append( $("<td/>").attr(td_attrs).text("△") );
$("#nittei tr:first").append( $("<td/>").attr(td_attrs).text("×") );
$("#nittei tr:gt(0)").each(function(){
if($("td:first", this).text() == "コメント"){
return;
}
var mark_circle = 0;
var mark_triangle = 0;
var mark_times = 0;
$("td:gt(0)", this).each(function(){
var mark = $(this).text();
if(mark == "○"){
mark_circle++;
} else if(mark == "△"){
mark_triangle++;
} else if(mark == "×"){
mark_times++;
}
});
$(this).append( $("<td/>").attr(td_attrs).text(mark_circle + mark_triangle) );
$(this).append( $("<td/>").attr(td_attrs).text(mark_circle) );
$(this).append( $("<td/>").attr(td_attrs).text(mark_triangle) );
$(this).append( $("<td/>").attr(td_attrs).text(mark_times) );
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment