feat: wip

This commit is contained in:
DIYgod
2019-07-21 11:59:09 +08:00
parent b488bcf6e6
commit d6033e0ddc
8 changed files with 48 additions and 36 deletions
+2 -1
View File
@@ -41,6 +41,7 @@
"webpack-cli": "3.3.6"
},
"dependencies": {
"clipboard": "2.0.4"
"clipboard": "2.0.4",
"route-recognizer": "0.3.4"
}
}
+2 -1
View File
@@ -18,6 +18,7 @@
"persistent": false
},
"permissions": [
"activeTab"
"activeTab",
"tabs"
]
}
+2 -2
View File
@@ -1,7 +1,7 @@
body {
width: 310px;
margin: 0;
padding: 15px 20px 20px;
padding: 15px 20px 10px;
font-family: "Helvetica Neue",Helvetica,"PingFang SC","Hiragino Sans GB","Microsoft YaHei","微软雅黑",Arial,sans-serif;
}
@@ -17,7 +17,6 @@ body {
ul,
li {
margin: 0;
padding: 0;
list-style-type: none;
}
@@ -49,6 +48,7 @@ body {
display: flex;
justify-content: space-between;
height: 30px;
margin-bottom: 10px;
.rss-image {
width: 30px;
+3 -4
View File
@@ -1,14 +1,13 @@
import { handlePageRSS, handlePageRSSHub, handleWebsiteRSSHub } from './utils';
import rules from './rules';
import { handleRSS } from './utils';
chrome.tabs.onActivated.addListener(function (tab) {
chrome.tabs.sendMessage(tab.tabId, {
text: 'getPageRSS',
}, handlePageRSS);
}, handleRSS);
});
chrome.runtime.onMessage.addListener(function (msg, sender, sendResponse) {
if (msg.text === 'setPageRSS' && sender.tab.active) {
handlePageRSS(msg.feeds);
handleRSS(msg.feeds);
}
});
+1 -1
View File
@@ -4,7 +4,7 @@ module.exports = {
title: '分区视频',
source: '/v/*tpath',
target: (params) => {
const tid;
let tid;
switch (params.tpath) {
case 'douga/mad':
tid = '24';
+32 -22
View File
@@ -1,3 +1,5 @@
import rules from './rules';
window.pageRSS = [];
window.pageRSSHub = [];
window.websiteRSSHub = [];
@@ -6,34 +8,42 @@ chrome.browserAction.setBadgeBackgroundColor({
color: '#FF2800',
});
function setBadge () {
function setBadge (id) {
chrome.browserAction.setBadgeText({
text: ((window.pageRSS.length + window.pageRSSHub.length) || '') + '',
tabId: id,
});
}
function getPageRSSHub (url, done) {
console.log(url);
done([]);
}
function getWebsiteRSSHub (url) {
return [];
}
export function handleRSS (feeds) {
chrome.tabs.query({
active: true,
currentWindow: true,
}, (tabs) => {
chrome.browserAction.setBadgeText({
text: (window.pageRSS.length + window.pageRSSHub.length) ? (window.pageRSS.length + window.pageRSSHub.length + '') : '',
tabId: tabs[0].id,
console.log(tabs);
const currentTab = tabs[0];
feeds && feeds.forEach((feed) => {
feed.image = currentTab.favIconUrl || feed.image;
});
});
}
window.pageRSS = feeds || [];
function handlePageRSS (feeds) {
window.pageRSS = feeds || [];
setBadge();
}
getPageRSSHub(currentTab.url, (feeds) => {
window.pageRSSHub = feeds || [];
setBadge(currentTab.id);
});
function handlePageRSSHub (feeds) {
window.pageRSSHub = feeds || [];
setBadge();
}
window.websiteRSSHub = getWebsiteRSSHub(currentTab.url) || [];
function handleWebsiteRSSHub (feeds) {
window.websiteRSSHub = feeds || [];
}
module.exports = {
handlePageRSS,
handlePageRSSHub,
handleWebsiteRSSHub,
setBadge(currentTab.id);
});
}
+1 -5
View File
@@ -11,7 +11,7 @@ function handleUrl (url) {
return url;
}
function getPageRSS () {
export function getPageRSS () {
if (!pageRSS) {
pageRSS = [];
let types = [
@@ -45,8 +45,4 @@ function getPageRSS () {
}
}
return pageRSS;
}
module.exports = {
getPageRSS,
}
+5
View File
@@ -4610,6 +4610,11 @@ ripemd160@^2.0.0, ripemd160@^2.0.1:
hash-base "^3.0.0"
inherits "^2.0.1"
route-recognizer@0.3.4:
version "0.3.4"
resolved "https://registry.yarnpkg.com/route-recognizer/-/route-recognizer-0.3.4.tgz#39ab1ffbce1c59e6d2bdca416f0932611e4f3ca3"
integrity sha512-2+MhsfPhvauN1O8KaXpXAOfR/fwe8dnUXVM+xw7yt40lJRfPVQxV6yryZm0cgRvAj5fMF/mdRZbL2ptwbs5i2g==
run-queue@^1.0.0, run-queue@^1.0.3:
version "1.0.3"
resolved "https://registry.yarnpkg.com/run-queue/-/run-queue-1.0.3.tgz#e848396f057d223f24386924618e25694161ec47"