diff --git a/_locales/en/messages.json b/_locales/en/messages.json
index a71878b..b3191f2 100644
--- a/_locales/en/messages.json
+++ b/_locales/en/messages.json
@@ -424,5 +424,14 @@
},
"refresh": {
"message": "refresh"
+ },
+ "generateQr": {
+ "message": "url generate QrCode"
+ },
+ "tabsMenu": {
+ "message": "tabs menu"
+ },
+ "remindMenu": {
+ "message": "remind menu"
}
}
\ No newline at end of file
diff --git a/_locales/zh_CN/messages.json b/_locales/zh_CN/messages.json
index 3abd9f5..c8ac632 100644
--- a/_locales/zh_CN/messages.json
+++ b/_locales/zh_CN/messages.json
@@ -424,5 +424,14 @@
},
"refresh": {
"message": "刷新"
+ },
+ "generateQr": {
+ "message": "网址生成二维码"
+ },
+ "tabsMenu": {
+ "message": "标签功能菜单"
+ },
+ "remindMenu": {
+ "message": "定时功能菜单"
}
}
\ No newline at end of file
diff --git a/css/popup.css b/css/popup.css
index f5b53e0..ef067f2 100644
--- a/css/popup.css
+++ b/css/popup.css
@@ -1,5 +1,4 @@
.menu-entry {
- text-align: center;
font-size: 100%;
background: #fefefe;
padding: 10px;
diff --git a/js/background.js b/js/background.js
index 91a6dff..4a281de 100644
--- a/js/background.js
+++ b/js/background.js
@@ -965,6 +965,7 @@ function remind(minute) {
// 时间到,清除定时器
clearTimeout(timeoutId);
surplusTime = undefined;
+ chrome.contextMenus.update("1", { title: `${chrome.i18n.getMessage("remindStatus")}` }, function callback() { })
}, minute * 60 * 1000);
var endDateStr = new Date();
var min = endDateStr.getMinutes();
@@ -1000,7 +1001,7 @@ function timeDown(endDateStr) {
timeoutId = setTimeout(function () {
timeDown(endDateStr);
}, 1000)
-
+ chrome.contextMenus.update("1", { title: surplusTime }, function callback() { })
}
// 判断是否int
@@ -1193,4 +1194,175 @@ chrome.storage.onChanged.addListener(function (changes, areaName) {
} else {
console.log("不要同步")
}
+});
+
+
+chrome.contextMenus.create({
+ id: "1",
+ title: `${chrome.i18n.getMessage("remindStatus")}`,
+ contexts: ["browser_action"]
+});
+
+chrome.contextMenus.create({
+ id: "2",
+ title: `${chrome.i18n.getMessage("generateQr")}`,
+ contexts: ["browser_action"],
+ onclick: function () {
+ chrome.tabs.query({ url: ["https://*/*", "http://*/*"], active: true, currentWindow: true }, function (tab) {
+ console.log(tab)
+ if (tab.length > 0) {
+ data = tab[0].url;
+ let qrInfo = ``
+ sendMessageToContentScript("generateQr", qrInfo);
+ }
+ });
+ }
+});
+
+chrome.contextMenus.create({
+ id: "3",
+ title: `${chrome.i18n.getMessage("tabsMenu")}`,
+ contexts: ["browser_action"]
+});
+
+chrome.contextMenus.create({
+ id: "4",
+ title: `${chrome.i18n.getMessage("showAllTabs")}`,
+ contexts: ["browser_action"],
+ onclick: function () {
+ openBackgroundPage();
+ },
+ parentId: "3"
+});
+
+chrome.contextMenus.create({
+ id: "5",
+ title: `${chrome.i18n.getMessage("sendAllTabs")}`,
+ contexts: ["browser_action"],
+ onclick: function () {
+ chrome.tabs.query({ url: ["https://*/*", "http://*/*"], currentWindow: true }, function (req) {
+ if (req.length > 0) {
+ saveTabs(req);
+ openBackgroundPage();
+ closeTabs(req);
+ } else {
+ openBackgroundPage();
+ }
+ });
+ },
+ parentId: "3"
+});
+
+
+chrome.contextMenus.create({
+ id: "6",
+ title: `${chrome.i18n.getMessage("sendCurrentTab")}`,
+ contexts: ["browser_action"],
+ onclick: function () {
+ chrome.storage.local.get(function (storage) {
+ let opts = storage.options
+ let openBackgroundAfterSendTab = "yes"
+ if (opts) {
+ openBackgroundAfterSendTab = opts.openBackgroundAfterSendTab || "yes"
+ }
+ chrome.tabs.query({ url: ["https://*/*", "http://*/*"], highlighted: true, currentWindow: true }, function (req) {
+ if (req.length > 0) {
+ saveTabs(req);
+ if (openBackgroundAfterSendTab === "yes") {
+ openBackgroundPage();
+ }
+ closeTabs(req);
+ } else {
+ if (openBackgroundAfterSendTab === "yes") {
+ openBackgroundPage();
+ }
+ }
+ });
+ })
+ },
+ parentId: "3"
+});
+
+
+chrome.contextMenus.create({
+ id: "7",
+ title: `${chrome.i18n.getMessage("sendOtherTabs")}`,
+ contexts: ["browser_action"],
+ onclick: function () {
+ chrome.tabs.query({ url: ["https://*/*", "http://*/*"], active: false, currentWindow: true }, function (req) {
+ if (req.length > 0) {
+ saveTabs(req);
+ openBackgroundPage();
+ closeTabs(req);
+ } else {
+ openBackgroundPage();
+ }
+ });
+ },
+ parentId: "3"
+});
+
+
+chrome.contextMenus.create({
+ id: "8",
+ title: `${chrome.i18n.getMessage("remindMenu")}`,
+ contexts: ["browser_action"]
+});
+
+chrome.contextMenus.create({
+ id: "9",
+ title: `${chrome.i18n.getMessage("fiveMinuteRemind")}`,
+ contexts: ["browser_action"],
+ onclick: function () {
+ remind(5);
+ },
+ parentId: "8"
+});
+
+
+chrome.contextMenus.create({
+ id: "10",
+ title: `${chrome.i18n.getMessage("tenMinuteRemind")}`,
+ contexts: ["browser_action"],
+ onclick: function () {
+ remind(10);
+ },
+ parentId: "8"
+});
+
+
+chrome.contextMenus.create({
+ id: "11",
+ title: `${chrome.i18n.getMessage("fortyMinuteRemind")}`,
+ contexts: ["browser_action"],
+ onclick: function () {
+ remind(40);
+ },
+ parentId: "8"
+});
+
+
+chrome.contextMenus.create({
+ id: "12",
+ title: `${chrome.i18n.getMessage("customMinuteRemind")}`,
+ contexts: ["browser_action"],
+ onclick: function () {
+ var minute = prompt(`${chrome.i18n.getMessage("pleaseInputCustomMinute")}`, 120);
+ if (!isInt(parseInt(minute.trim()))) {
+ alert(`${chrome.i18n.getMessage("inputNumber")}`)
+ } else {
+ remind(Number(minute.trim()));
+ }
+ },
+ parentId: "8"
+});
+
+
+chrome.contextMenus.create({
+ id: "13",
+ title: `${chrome.i18n.getMessage("openJsonTools")}`,
+ contexts: ["browser_action"],
+ onclick: function () {
+ chrome.tabs.create({ index: 0, url: chrome.extension.getURL('json.html') });
+ }
});
\ No newline at end of file
diff --git a/js/contentscript.js b/js/contentscript.js
index 7fe07a4..3da78ce 100644
--- a/js/contentscript.js
+++ b/js/contentscript.js
@@ -53,6 +53,14 @@ chrome.runtime.onMessage.addListener(function (req, sender, sendRes) {
sendRes('ok'); // acknowledge
tip(req.message);
break;
+ case 'generateQr':
+ sendRes('ok'); // acknowledge
+ var screenWidth = document.body.clientWidth + document.body.scrollLeft;
+ pageX = screenWidth / 2
+ pageY = 70
+ scrollTop = 0
+ tip(req.message);
+ break;
default:
sendRes('nope'); // acknowledge
break;
diff --git a/js/popup.js b/js/popup.js
index 8019075..7386964 100644
--- a/js/popup.js
+++ b/js/popup.js
@@ -8,181 +8,181 @@
document.addEventListener('DOMContentLoaded', function () {
console.log("load完popup了");
var data;
- chrome.tabs.query({ active: true, currentWindow: true }, function (tab) {
- data = tab[0].url;
- $("#qr").attr("src", "http://qr.topscan.com/api.php?text=" + data);
- $("#qr").css({ "width": "200px", "height": "200px" });
- });
+ if (navigator.userAgent.toLowerCase().match(/qqbrowser/) != null) {
- document.getElementById("menu").innerHTML = `
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- `;
+ chrome.tabs.query({ active: true, currentWindow: true }, function (tab) {
+ data = tab[0].url;
+ $("#qr").attr("src", "http://qr.topscan.com/api.php?text=" + data);
+ $("#qr").css({ "width": "200px", "height": "200px" });
+ });
- document.getElementById("deadLine").innerHTML = `
-
-
-
- `;
- //
- //
- //
- //
- //
- //
+ document.getElementById("menu").innerHTML = `
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ `;
- // 发送所有tab
- document.getElementById('save-all').addEventListener('click', function () {
- chrome.tabs.query({ url: ["https://*/*", "http://*/*"], currentWindow: true }, function (tabsArr) {
- chrome.runtime.sendMessage({ action: 'save-all', tabsArr: tabsArr }, function (res) {
- if (res === 'ok') {
- window.close();
- }
+ // 发送所有tab
+ document.getElementById('save-all').addEventListener('click', function () {
+ chrome.tabs.query({ url: ["https://*/*", "http://*/*"], currentWindow: true }, function (tabsArr) {
+ chrome.runtime.sendMessage({ action: 'save-all', tabsArr: tabsArr }, function (res) {
+ if (res === 'ok') {
+ window.close();
+ }
+ });
});
});
- });
- // 发送其他tab
- document.getElementById('save-others').addEventListener('click', function () {
- chrome.tabs.query({ url: ["https://*/*", "http://*/*"], active: false, currentWindow: true }, function (tabsArr) {
- chrome.runtime.sendMessage({ action: 'save-others', tabsArr: tabsArr }, function (res) {
- if (res === 'ok') {
- window.close();
- }
+ // 发送其他tab
+ document.getElementById('save-others').addEventListener('click', function () {
+ chrome.tabs.query({ url: ["https://*/*", "http://*/*"], active: false, currentWindow: true }, function (tabsArr) {
+ chrome.runtime.sendMessage({ action: 'save-others', tabsArr: tabsArr }, function (res) {
+ if (res === 'ok') {
+ window.close();
+ }
+ });
+ });
+ });
+
+ // 发送当前tab
+ document.getElementById('save-current').addEventListener('click', function () {
+ chrome.tabs.query({ url: ["https://*/*", "http://*/*"], highlighted: true, currentWindow: true }, function (tabsArr) {
+ chrome.runtime.sendMessage({ action: 'save-current', tabsArr: tabsArr }, function (res) {
+ if (res === 'ok') {
+ window.close();
+ }
+ });
});
});
- });
- // 发送当前tab
- document.getElementById('save-current').addEventListener('click', function () {
- chrome.tabs.query({ url: ["https://*/*", "http://*/*"], highlighted: true, currentWindow: true }, function (tabsArr) {
- chrome.runtime.sendMessage({ action: 'save-current', tabsArr: tabsArr }, function (res) {
+ // open background page
+ document.getElementById('open-background-page').addEventListener('click', function () {
+ chrome.runtime.sendMessage({ action: 'openbackgroundpage' }, function (res) {
if (res === 'ok') {
window.close();
}
});
});
- });
- // open background page
- document.getElementById('open-background-page').addEventListener('click', function () {
- chrome.runtime.sendMessage({ action: 'openbackgroundpage' }, function (res) {
- if (res === 'ok') {
- window.close();
- }
+ // 打开json工具页
+ document.getElementById('open_json_html').addEventListener('click', function () {
+ chrome.tabs.create({ index: 0, url: chrome.extension.getURL('json.html') });
});
- });
-
- // 打开json工具页
- document.getElementById('open_json_html').addEventListener('click', function () {
- chrome.tabs.create({ index: 0, url: chrome.extension.getURL('json.html') });
- });
- // 测试用
- // document.getElementById('testGithub').addEventListener('click', function () {
- // // chrome.tabs.create({ index: 0, url: chrome.extension.getURL('woc.html') });
- // console.log("点了")
- // chrome.runtime.sendMessage({ action: 'testGithub' }, function (res) {
- // if (res === 'ok') {
- // }
- // });
- // });
- // document.getElementById('test').addEventListener('click', function () {
- // // chrome.tabs.create({ index: 0, url: chrome.extension.getURL('woc.html') });
- // console.log("点了")
- // chrome.runtime.sendMessage({ action: 'test' }, function (res) {
- // if (res === 'ok') {
- // }
- // });
- // });
-
- // 5分钟定时提醒
- document.getElementById('five-minute').addEventListener('click', function () {
- chrome.runtime.sendMessage({ action: 'five-minute' }, function (res) {
- if (res === 'ok') {
- window.close();
- }
- });
- });
+ // 测试用
+ // document.getElementById('testGithub').addEventListener('click', function () {
+ // // chrome.tabs.create({ index: 0, url: chrome.extension.getURL('woc.html') });
+ // console.log("点了")
+ // chrome.runtime.sendMessage({ action: 'testGithub' }, function (res) {
+ // if (res === 'ok') {
+ // }
+ // });
+ // });
+ // document.getElementById('test').addEventListener('click', function () {
+ // // chrome.tabs.create({ index: 0, url: chrome.extension.getURL('woc.html') });
+ // console.log("点了")
+ // chrome.runtime.sendMessage({ action: 'test' }, function (res) {
+ // if (res === 'ok') {
+ // }
+ // });
+ // });
- // 10分钟定时提醒
- document.getElementById('ten-minute').addEventListener('click', function () {
- chrome.runtime.sendMessage({ action: 'ten-minute' }, function (res) {
- if (res === 'ok') {
- window.close();
- }
+ // 5分钟定时提醒
+ document.getElementById('five-minute').addEventListener('click', function () {
+ chrome.runtime.sendMessage({ action: 'five-minute' }, function (res) {
+ if (res === 'ok') {
+ window.close();
+ }
+ });
});
- });
- // 40分钟定时提醒
- document.getElementById('forty-minute').addEventListener('click', function () {
- chrome.runtime.sendMessage({ action: 'forty-minute' }, function (res) {
- if (res === 'ok') {
- window.close();
- }
+ // 10分钟定时提醒
+ document.getElementById('ten-minute').addEventListener('click', function () {
+ chrome.runtime.sendMessage({ action: 'ten-minute' }, function (res) {
+ if (res === 'ok') {
+ window.close();
+ }
+ });
});
- });
- // 自定义分钟数的定时提醒
- document.getElementById('custom-minute').addEventListener('click', function () {
- var minute = prompt(`${chrome.i18n.getMessage("pleaseInputCustomMinute")}`, 120);
- if (!isInt(parseInt(minute.trim()))) {
- alert(`${chrome.i18n.getMessage("inputNumber")}`)
- } else {
- chrome.runtime.sendMessage({ action: 'custom-minute', message: minute.trim() }, function (res) {
+ // 40分钟定时提醒
+ document.getElementById('forty-minute').addEventListener('click', function () {
+ chrome.runtime.sendMessage({ action: 'forty-minute' }, function (res) {
if (res === 'ok') {
window.close();
}
});
- }
- });
+ });
- // 通过定时器获取倒计时的样子
- var bg = chrome.extension.getBackgroundPage();
- if (typeof (bg.surplusTime) != "undefined") {
- intervalId = setInterval(function () {
- if (typeof (bg.surplusTime) != "undefined") {
- document.getElementById('surplusTime').innerHTML = bg.surplusTime;
+ // 自定义分钟数的定时提醒
+ document.getElementById('custom-minute').addEventListener('click', function () {
+ var minute = prompt(`${chrome.i18n.getMessage("pleaseInputCustomMinute")}`, 120);
+ if (!isInt(parseInt(minute.trim()))) {
+ alert(`${chrome.i18n.getMessage("inputNumber")}`)
} else {
- clearInterval(intervalId);
- document.getElementById('surplusTime').innerHTML = `${chrome.i18n.getMessage("remindStatus")}`;
+ chrome.runtime.sendMessage({ action: 'custom-minute', message: minute.trim() }, function (res) {
+ if (res === 'ok') {
+ window.close();
+ }
+ });
}
- }, 1000);
- } else {
- clearInterval(intervalId);
- document.getElementById('surplusTime').innerHTML = `${chrome.i18n.getMessage("remindStatus")}`;
- };
+ });
+
+ // 通过定时器获取倒计时的样子
+ var bg = chrome.extension.getBackgroundPage();
+ if (typeof (bg.surplusTime) != "undefined") {
+ intervalId = setInterval(function () {
+ if (typeof (bg.surplusTime) != "undefined") {
+ document.getElementById('surplusTime').innerHTML = bg.surplusTime;
+ } else {
+ clearInterval(intervalId);
+ document.getElementById('surplusTime').innerHTML = `${chrome.i18n.getMessage("remindStatus")}`;
+ }
+ }, 1000);
+ } else {
+ clearInterval(intervalId);
+ document.getElementById('surplusTime').innerHTML = `${chrome.i18n.getMessage("remindStatus")}`;
+ };
+ }
+
+ document.getElementById("deadLine").innerHTML = `
+
+
+
+ `;
+ //
+ //
+ //
});
diff --git a/manifest.json b/manifest.json
index 3528d35..d76f814 100644
--- a/manifest.json
+++ b/manifest.json
@@ -1,5 +1,5 @@
{
- "version": "2.0.0",
+ "version": "2.0.1",
"name": "cloudSkyMonster",
"manifest_version": 2,
"description": "__MSG_pluginDesc__",
diff --git a/popup.html b/popup.html
index b66ab80..a22d14e 100644
--- a/popup.html
+++ b/popup.html
@@ -12,9 +12,9 @@