Skip to content

Commit

Permalink
Replace pages that can not be opened
Browse files Browse the repository at this point in the history
  • Loading branch information
sienori committed Nov 22, 2017
1 parent f1040a1 commit 789c4d4
Show file tree
Hide file tree
Showing 9 changed files with 109 additions and 5 deletions.
5 changes: 5 additions & 0 deletions Tab-Session-Manager/_locales/en/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -172,5 +172,10 @@
},
"amazonUrl": {
"message": "https://www.amazon.co.jp/dp/B004N3APGO?language=en_US"
},


"replacedPageMessage": {
"message": "This page can not be opened by Tab Session Manager."
}
}
5 changes: 5 additions & 0 deletions Tab-Session-Manager/_locales/ja/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -172,5 +172,10 @@
},
"amazonUrl": {
"message": "https://www.amazon.co.jp/dp/B004N3APGO?language=ja_JP"
},


"replacedPageMessage": {
"message": "このページはTab Session Managerでは開けません。"
}
}
5 changes: 5 additions & 0 deletions Tab-Session-Manager/_locales/ru/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -172,5 +172,10 @@
},
"amazonUrl": {
"message": "https://www.amazon.co.jp/dp/B004N3APGO?language=en_US"
},


"replacedPageMessage": {
"message": "This page can not be opened by Tab Session Manager."
}
}
5 changes: 5 additions & 0 deletions Tab-Session-Manager/_locales/zh_CN/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -172,5 +172,10 @@
},
"amazonUrl": {
"message": "https://www.amazon.co.jp/dp/B004N3APGO?language=zh_CN"
},


"replacedPageMessage": {
"message": "This page can not be opened by Tab Session Manager."
}
}
5 changes: 5 additions & 0 deletions Tab-Session-Manager/_locales/zh_TW/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -173,5 +173,10 @@
},
"amazonUrl": {
"message": "https://www.amazon.co.jp/dp/B004N3APGO?language=zh_CN"
},


"replacedPageMessage": {
"message": "This page can not be opened by Tab Session Manager."
}
}
13 changes: 8 additions & 5 deletions Tab-Session-Manager/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -320,11 +320,6 @@ function openTab(session, win, currentWindow, tab) {
return new Promise(function (resolve, reject) {
property = session.windows[win][tab];

//特殊ページは新しいタブに置き換える
if (property.url == "about:newtab" || property.url == "about:config" || property.url == "about:addons" || property.url == "about:debugging") {
property.url = null;
}

let createOption = {
active: property.active,
cookieStoreId: property.cookieStoreId,
Expand All @@ -345,6 +340,14 @@ function openTab(session, win, currentWindow, tab) {
browser.tabs.create(createOption).then(function (newTab) {
tabList[property.id] = newTab.id;
resolve();
}, function () { //タブオープン失敗時
createOption.url = "replaced/replaced.html" + "?tst_title=" + property.title + "&tst_url=" + property.url;
browser.tabs.create(createOption).then(function (newTab) {
tabList[property.id] = newTab.id;
resolve();
}, function () {
resolve();
})
});
}, openDelay) //ツリー型タブの処理を待つ
})
Expand Down
48 changes: 48 additions & 0 deletions Tab-Session-Manager/replaced/replaced.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
:root {
--main-text: #0c0c0d;
--sub-text: #737373;
--line: #ededf0;
--button: #d7d7db;
--highlight: #36b2b2;
--main-bg: #ffffff;
}

body {
font-family: 'Segoe UI', 'San Francisco', 'Ubuntu', 'Fira Sans', 'Roboto', 'Arial', 'Helvetica', sans-serif;
font-size: 15px;
font-weight: 400;
color: var(--main-text);
background-color: var(--main-bg);
line-height: 1.5;
display: flex;
flex-direction: row;
}

.container {
display: flex;
flex-direction: column;
width: 100%;
padding-left: 20px;
}

.replacedUrl {
font-size: 33px;
font-weight: 200;
color: var(--sub-text);
line-height: 2;
}

.caption {
font-size: 13px;
font-weight: 400;
color: var(--sub-text);
}

hr {
width: 100%;
background-color: var(--line);
height: 1px;
border: none;
margin-top: 20px;
margin-bottom: 20px;
}
18 changes: 18 additions & 0 deletions Tab-Session-Manager/replaced/replaced.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<!doctype html>
<html>

<head>
<meta charset="UTF-8">
<link rel="stylesheet" type="text/css" href="replaced.css">
<title>Replaced</title>
</head>

<body>
<div class=container>
<div class=replacedUrl>about:example</div>
<div id=replacedPageMessage class=caption>このページはTab Session Managerでは開くことが出来ません。</div>
</div>
<script type="text/javascript" src="replaced.js"></script>
</body>

</html>
10 changes: 10 additions & 0 deletions Tab-Session-Manager/replaced/replaced.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */

let title = location.href.split('?tst_title=').slice(1).join('?').split('&tst_url')[0];
let url = location.href.split('&tst_url=').slice(1).join('?');

document.title = decodeURI(title);
document.getElementsByClassName("replacedUrl")[0].innerText = decodeURI(url);
document.getElementById("replacedPageMessage").innerText = browser.i18n.getMessage("replacedPageMessage");

0 comments on commit 789c4d4

Please sign in to comment.