Edited at

チャットワークの部屋とメンバーの関係を表で出す

More than 1 year has passed since last update.


手順



  1. https://www.chatwork.com/ へアクセス

  2. ブラウザの開発者ツールを開いて下をコピペ

  3. ポップアップがブロックされるので許可


圧縮版

var members={};$.each(RL.rooms,function(e,t){"contact"!=t.type&&$.each(t.member_dat,function(e){members[AC.getName(e)]=!0})});var table=document.createElement("table"),tr=document.createElement("tr");table.appendChild(tr);var td=document.createElement("td");td.innerText="",tr.appendChild(td);for(name in members){var td=document.createElement("td");td.innerText=name,tr.appendChild(td)}$.each(RL.rooms,function(e,t){if("contact"!=t.type){var n=document.createElement("tr");table.appendChild(n);var r=document.createElement("td");r.innerText=t._name,n.appendChild(r);for(name in members){var d=!1,a=!1;$.each(t.member_dat,function(e,t){AC.getName(e)==name&&(d=!0,"admin"==t&&(a=!0))});var r=document.createElement("td");r.innerText=d?a?"":"":"",n.appendChild(r)}}});var style="<style>body { padding: 1em; }tr:first-child { background-color: #D3E8C1; }tr:nth-child(2n) { background-color: #FFE6CE; }table { border: #999999 2px solid; border-collapse: collapse; }tr:nth-child(5n+1) { border-bottom: #999999 2px solid; }td:nth-child(5n+1) { border-right: #999999 2px solid; }td { border: #cccccc 1px solid; text-align: center; }td:first-child { text-align: left; }</style>",uri="data:text/html;charset=utf-8, "+encodeURIComponent(style+table.outerHTML),link=document.createElement("a");link.href=uri,link.target="_blank",link.download="test.html",document.body.appendChild(link),link.click(),document.body.removeChild(link);


非圧縮版

var members = {}

$.each(RL.rooms,function(i,r){
if (r.type=="contact"){return;}
$.each(r.member_dat,function(m){
members[AC.getName(m)] = true;
})
})

var table = document.createElement("table");
var tr = document.createElement("tr");
table.appendChild(tr);
var td = document.createElement("td");
td.innerText = "";
tr.appendChild(td);
for( name in members ){
var td = document.createElement("td");
td.innerText = name;
tr.appendChild(td);
}

$.each(RL.rooms,function(i,r){
if (r.type=="contact"){return;}
var tr = document.createElement("tr");
table.appendChild(tr);
var td = document.createElement("td");
td.innerText = r._name;
tr.appendChild(td);
for( name in members ){
var flag = false;
var is_admin = false;
$.each(r.member_dat,function(m, val){
if (AC.getName(m) == name) {
flag = true;
if (val == "admin") {is_admin = true;}
}
})
var td = document.createElement("td");
td.innerText = flag ? ( is_admin ? "" : "" ) : "";
tr.appendChild(td);
}
})

var style = "<style>" +
"body { padding: 1em; }" +
"tr:first-child { background-color: #D3E8C1; }" +
"tr:nth-child(2n) { background-color: #FFE6CE; }" +
"table { border: #999999 2px solid; border-collapse: collapse; }" +
"tr:nth-child(5n+1) { border-bottom: #999999 2px solid; }" +
"td:nth-child(5n+1) { border-right: #999999 2px solid; }" +
"td { border: #cccccc 1px solid; text-align: center; }" +
"td:first-child { text-align: left; }" +
"</style>";

var uri = 'data:text/html;charset=utf-8, ' + encodeURIComponent(style+table.outerHTML);
var link = document.createElement('a');
link.href = uri;
link.target = '_blank';
link.download = "test.html";
document.body.appendChild(link);
link.click();
document.body.removeChild(link);

cssは @circled9 さんに作ってもらいました。 :pray: