Skip to content

Commit

Permalink
first code commit
Browse files Browse the repository at this point in the history
  • Loading branch information
takahyon committed Apr 12, 2020
1 parent b484449 commit 6152e09
Show file tree
Hide file tree
Showing 8 changed files with 278 additions and 0 deletions.
Empty file added css/contents_style.css
Empty file.
87 changes: 87 additions & 0 deletions css/popup.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
body{
margin: 0px;
width: 200px;
height: 200px;
}
/* === ボタンを表示するエリア ============================== */
.switchArea {
line-height : 48px; /* 1行の高さ */
letter-spacing : 0; /* 文字間 */
text-align : center; /* 文字位置は中央 */
font-size : 21px; /* 文字サイズ */

position : relative; /* 親要素が基点 */
margin : auto; /* 中央寄せ */
width : 114px; /* ボタンの横幅 */
background : #fff; /* デフォルト背景色 */
}

/* === チェックボックス ==================================== */
.switchArea input[type="checkbox"] {
display : none; /* チェックボックス非表示 */
}

/* === チェックボックスのラベル(標準) ==================== */
.switchArea label {
display : block; /* ボックス要素に変更 */
box-sizing : border-box; /* 枠線を含んだサイズ */
height : 48px; /* ボタンの高さ */
border : 2px solid rgba(0, 0, 0, 0.36); /* 未選択タブのの枠線 */
border-radius : 24px; /* 角丸 */
}

/* === チェックボックスのラベル(ONのとき) ================ */
.switchArea input[type="checkbox"]:checked +label {
border-color : #6666ff; /* 選択タブの枠線 */
}

/* === 表示する文字(標準) ================================ */
.switchArea label span:after{
content : "OFF"; /* 表示する文字 */
padding : 0 0 0 28px; /* 表示する位置 */
color : rgba(0, 0, 0, 0.36); /* 文字色 */
}

/* === 表示する文字(ONのとき) ============================ */
.switchArea input[type="checkbox"]:checked + label span:after{
content : "ON"; /* 表示する文字 */
padding : 0 28px 0 0; /* 表示する位置 */
color : #6666ff; /* 文字色 */
}

/* === 丸部分のSTYLE(標準) =============================== */
.switchArea #swImg {
position : absolute; /* 親要素からの相対位置*/
width : 40px; /* 丸の横幅 */
height : 40px; /* 丸の高さ */
background : rgba(0, 0, 0, 0.36); /* カーソルタブの背景 */
top : 4px; /* 親要素からの位置 */
left : 4px; /* 親要素からの位置 */
border-radius : 20px; /* 角丸 */
transition : .2s; /* 滑らか変化 */
}

/* === 丸部分のSTYLE(ONのとき) =========================== */
.switchArea input[type="checkbox"]:checked ~ #swImg {
transform : translateX(66px); /* 丸も右へ移動 */
background : #6666ff; /* カーソルタブの背景 */
}

.text{
text-align: center;
font-size: medium;
font-family: sans-serif;
}

.topBox{
width: 200px;
height: 40px;
background : #6666ff;
}
.topText{
text-align: center;
color: azure;
font-size: large;
padding: 10px;
font-family: 'Roboto', sans-serif;
}
46 changes: 46 additions & 0 deletions html/popup.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<!DOCTYPE html>
<html lang="ja">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link href='https://fonts.googleapis.com/css?family=Roboto' rel='stylesheet' type='text/css'>
<link href='../css/popup.css' rel='stylesheet' type='text/css'>
<title>Document</title>

</head>

<body>

<div class="topBox">
<div class="topText">
ND hidden Blocker
</div>
</div>


<div class="text">鍵ルームを非表示にする</div>
<br>
<div class="text">全てのルームを表示する</div>

<div class="switchArea">
<input type="checkbox" id="swi1">
<label for="swi1"><span></span></label>
<div id="swImg"></div>
</div>
<div class="text">現在、機能の無効化が未実装です。
これから実装いたしますので、お待ちください。
無効化を希望する方は、
</div>
<script type="text/javascript" src="../js/jquery.js"></script>

<script type="text/javascript" src="../js/popup.js"></script>

<!--
<div class="text">ルームを全て表示する</div>
<div class="switchArea">
<input type="checkbox" id="switch2">
<label for="switch1"><span></span></label>
<div id="swImg"></div>
</div> -->
</body>
</html>
Binary file added icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
65 changes: 65 additions & 0 deletions js/content_scripts/common.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
window.onload = function(){
chrome.storage.sync.get(['ndb'], function (result) {
switch (result.ndb){
case true:
enable();
break;
case false:
disable();
break;
case undefined:
enable();
break;
}
});
// オープンソースでアップしまーす!

function enable(){
show_all();
remove_locked();
ObserveStream();
}
function disable() {
console.log("test")
}
}
function show_all(){
for ( var i = 0; i < 10; i++ ) {
document.getElementById("moreroom").click();
}
}

function remove_locked() {
const base_url = "https://www.netduetto.net/room/img/"

const room_kill = base_url + "room_btn_kill.jpg"
const lock_room_on = base_url + "room_btn_lock_on.jpg"
const lock_room_off = base_url + "room_btn_lock_off.jpg"

var rawRoomItem = $(".roomItem")
var roomItem = Array.from(rawRoomItem)

roomItem.forEach(room => {
var img_src = room.getElementsByClassName("btn")[0].getElementsByTagName("a")[0].getElementsByTagName("img")[0].src;
this.console.log(img_src)
if(img_src == room_kill||img_src == lock_room_on||img_src == lock_room_off){
room.remove()
this.console.log('removed:'+room.innerText)
}
});
}

function ObserveStream(){
var observer = new MutationObserver(remove_locked);
observer.observe(document.getElementsByClassName('roomBox')[0], {
attributes: true,
childList: true
});
remove_locked();
}
var observer = new MutationObserver(ObserveStream);
observer.observe(document.body, {
attributes: true
});


2 changes: 2 additions & 0 deletions js/jquery.js

Large diffs are not rendered by default.

37 changes: 37 additions & 0 deletions js/popup.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
window.onload = function() {
console.log("1");
getObject();

// localStorageの文字列をJSONで取得
function getObject() {
console.log("2");
//var status = document.getElementById("swi1").checked;
var status = true
console.log(status)
chrome.storage.sync.get(['ndb'], function (result) {
console.log(result.ndb);
status = result.ndb;
if (status==undefined){
status = true;
setObject(status);
}
//document.getElementById("swi1").checked = status
});
};
// JSONを文字列でlocalStorageに保存
function setObject(selected) {
console.log("3");
chrome.storage.sync.set({'ndb':selected});
};

// オプションデータの更新
$('#switch1').change(function() {
console.log("6");
//var selected1 = document.getElementById("swi1").checked;
//setObject(selected1);
showStorage();
console.log("Update OK");
});
};


41 changes: 41 additions & 0 deletions manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
{
"manifest_version": 2,
"name": "ND-remove-unvisible",
"description": "Netduettoの非公開ルームをルームから除去します。 Netduetto extension for remove unvisible rooms from room list.",
"version": "1.0",
"icons": {
"16": "icon.png"
},
"background": {
"scripts": [
"js/jquery.js",
"js/popup.js"
],
"css": ["css/popup.css"],
"persistent": false
},
"browser_action": {
"default_icon": {
"19": "icon.png"
},
"default_title": "ND-remove-unvisible",
"default_popup": "html/popup.html"
},
"content_scripts": [
{
"matches": [
"https://www.netduetto.net/room/"
],
"css": ["css/contents_style.css","css/popup.css"],
"js": ["js/jquery.js",
"js/popup.js",
"js/content_scripts/common.js"]
}
],
"permissions": [
"tabs",
"https://*/*",
"http://*/*",
"storage"
]
}

0 comments on commit 6152e09

Please sign in to comment.