Skip to content

Commit

Permalink
Merge pull request #7 from takahyon/syncroom-utility
Browse files Browse the repository at this point in the history
Syncroom utility
  • Loading branch information
takahyon authored Aug 1, 2020
2 parents b973e1c + e697085 commit 895744b
Show file tree
Hide file tree
Showing 5 changed files with 77 additions and 67 deletions.
2 changes: 1 addition & 1 deletion css/popup.css
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
#ndHiddenBlocker .topBox {
width : 240px;
height : 40px;
background : #726C9F;
background : #255fcc;
}
#ndHiddenBlocker .topText {
text-align : center;
Expand Down
4 changes: 3 additions & 1 deletion html/popup.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

<div class="topBox">
<div class="topText">
ND Hidden Blocker
SYNCROOM Utility
</div>
</div>

Expand All @@ -22,6 +22,7 @@
<input type="checkbox" id="cbLockedRoom">
<label for="cbLockedRoom" class="checkboxLabel">鍵ルーム</label>
</div>
<!--
<div class="switchArea">
<input type="checkbox" id="cbNoVacancyRoom">
<label for="cbNoVacancyRoom" class="checkboxLabel">満室ルーム</label>
Expand All @@ -35,6 +36,7 @@
<small>※登録タグをクリックすると登録解除</small>
</div>
-->
<pre></pre>
</main>

Expand Down
124 changes: 66 additions & 58 deletions js/popup.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,75 +102,83 @@ function onClickRegiteredTag() {
*/
let isFirstTime = true;
function filterRoomBox(conditions) {
if (!$('#moreroom').length) { return; }
let intervalId = setInterval(function () {

// あらかじめすべての部屋分の DOM を生成しておく
// 消えるまでクリック (1 [msec] 置き)
if ($('#moreroom').css("display") != "none") {
$('#moreroom').click();
return;
}
// lockedRoom - 鍵付き部屋をフィルター 仮
let checked = $("#cond-status-private").prop("checked")
console.log(checked)
if (conditions[EID_CHECKBOX_LOCKEDROOM] && checked) {
$("#cond-status-private").trigger("click")
}

// roomsInnerを一覧として
let roomList = $("#macy-container .roomsInner")
//console.log(roomList)

if (!roomList.length) { return; }
let intervalId = setInterval(function () {

clearInterval(intervalId);

// for sorting
let highPriorityRooms = [];

$('.roomItem').each(function (index, element) {

// lockedRoom - 鍵付き部屋をフィルター
if (conditions[EID_CHECKBOX_LOCKEDROOM]) {
const imgPath = $(element).find('img').prop('src');
if (imgPath.match(/_lock/)) {
$(element).css('display', 'none');
return;
}
}

// noVacancyRoom - 満員部屋をフィルター
if (conditions[EID_CHECKBOX_NO_VACANCY_ROOM]) {
const peopleStr = $(element).find('p.people').text();
const peopleNum = parseInt(peopleStr.replace(/[^0-9]/g, ''));
if (peopleNum === PEOPLE_MAX) {
$(element).css('display', 'none');
return;
}
}

// listTag - 登録タグのついている部屋を上位に表示
roomList.each(function (index, element) {
// // lockedRoom - 鍵付き部屋をフィルター
// if (conditions[EID_CHECKBOX_LOCKEDROOM]) {
// if (!$(element).hasClass("enterable")) {
// $(element).css('display', 'none');
// return;
// }
// }

// // noVacancyRoom - 満員部屋をフィルター
// if (conditions[EID_CHECKBOX_NO_VACANCY_ROOM]) {
// if (!$(element).hasClass("enterable")) {
// $(element).css('display', 'none');
// return;
// }
// }

// TODO listTag - 登録タグのついている部屋を上位に表示
const listTagCondition = conditions[EID_LIST_TAG];
if (listTagCondition) {
if ($(element).data('sorted')) {
// 既にソートされた Room は何もしない
} else {
// まだソートされていない Room
let containsAtLeastOne = false; // 該当タグが最低 1 つ含まれているか
const roomTagElems = $(element).find('.roomtag');
for (let i = 0; i < roomTagElems.length; i++) {
const roomTagElem = $(roomTagElems[i]);
const targetTag = roomTagElem.text();
listTagCondition.forEach(tag => {
if (targetTag.indexOf(tag) !== -1) {
containsAtLeastOne = true;
roomTagElem.css('border-color', '#ff1493');
return;
}
});
}
if (containsAtLeastOne) {
// ソート対称
highPriorityRooms.unshift(element)
$(element).data('sorted', 1);
} else {
// ソート非対称
$(element).data('sorted', 0);
}
}
}
// if (listTagCondition && $("#cond-keyword").val()==="") {
// console.log(listTagCondition[0])
// $("#cond-keyword").val(listTagCondition[0])
// }


// if (listTagCondition) {
// if ($(element).data('sorted')) {
// // 既にソートされた Room は何もしない
// } else {
// // まだソートされていない Room
// let containsAtLeastOne = false; // 該当タグが最低 1 つ含まれているか
// const roomTagElems = $(element).find('.genre');
// for (let i = 0; i < roomTagElems.length; i++) {
// const roomTagElem = $(roomTagElems[i]);
// const targetTag = roomTagElem.text();
// listTagCondition.forEach(tag => {
// if (targetTag.indexOf(tag) !== -1) {
// containsAtLeastOne = true;
// roomTagElem.css('border-color', '#ff1493');
// return;
// }
// });
// }
// if (containsAtLeastOne) {
// // ソート対称
// highPriorityRooms.unshift(element)
// $(element).data('sorted', 1);
// } else {
// // ソート非対称
// $(element).data('sorted', 0);
// }
// }
// }
});

const roomBox = $('#containerRoom > ul')[0];
const roomBox = roomList[0];
for (let i = 0; i < highPriorityRooms.length; i++) {
// 先頭に移動
$(roomBox).prepend(highPriorityRooms[i]);
Expand Down
10 changes: 5 additions & 5 deletions manifest.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"manifest_version": 2,
"name": "ND-remove-unvisible",
"description": "Netduettoの非公開ルームをルームから除去します。 Netduetto extension for remove unvisible rooms from room list.",
"version": "2.2.0",
"name": "SYNCROOM-utility",
"description": "SYNCROOMのプレイヤーズサイトを便利にします!",
"version": "4.0.0",
"icons": {
"16": "icon_16.png"
},
Expand All @@ -19,13 +19,13 @@
"48": "icon_48.png",
"128": "icon_128.png"
},
"default_title": "ND-remove-unvisible",
"default_title": "syncroom-utility",
"default_popup": "html/popup.html"
},
"content_scripts": [
{
"matches": [
"https://www.netduetto.net/room/"
"https://syncroom.yamaha.com/play/"
],
"run_at": "document_idle",
"css": ["css/popup.css"],
Expand Down
4 changes: 2 additions & 2 deletions readme.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# ND-Visible
"description": "Netduettoの非公開ルームをルームから除去します。 Netduetto extension for remove unvisible rooms from room list.",
# SYNCROOM-utility
"SYNCROOMの非公開ルームをルームから除去します。 Netduetto extension for remove unvisible rooms from room list.",

# Chrome Web Store
https://chrome.google.com/webstore/detail/nd-remove-unvisible/kidafnplboigcfammdmmbabmjfdgeimh
Expand Down

0 comments on commit 895744b

Please sign in to comment.