Skip to content

Commit f30ce2a

Browse files
committed
Merge branch 'tmp'
2 parents 74ccf37 + abfb87f commit f30ce2a

File tree

7 files changed

+57
-146
lines changed

7 files changed

+57
-146
lines changed

extension/background.js

Lines changed: 51 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,52 @@
1-
// TODO: Move bg-test.js back here
2-
try {
3-
importScripts("bg-test.js");
4-
} catch (e) {
5-
console.error(e);
1+
chrome.runtime.onStartup.addListener(initPlugin);
2+
chrome.runtime.onInstalled.addListener(initPlugin);
3+
chrome.tabs.onActivated.addListener(recheckPlugin);
4+
let enabled = true;
5+
6+
function onClick() {
7+
if (enabled) {
8+
disable();
9+
}
10+
else {
11+
enable();
12+
}
13+
}
14+
15+
function initPlugin() {
16+
chrome.storage.local.get('dcr-enabled', function(res) {
17+
enabled = res;
18+
chrome.action.onClicked.addListener(onClick);
19+
chrome.runtime.onSuspend.addListener(cleanupPlugin);
20+
});
21+
}
22+
23+
function cleanupPlugin() {
24+
chrome.storage.local.set({'dcr-enabled': enabled});
25+
}
26+
27+
function recheckPlugin() {
28+
if (enabled)
29+
enable();
30+
else
31+
disable();
32+
}
33+
34+
function enable() {
35+
console.log("bg enable");
36+
enabled = true;
37+
chrome.tabs.query({active: true, currentWindow: true}, function(tabs){
38+
chrome.tabs.sendMessage(tabs[0].id, {message: 'dcr-enable'});
39+
});
40+
chrome.action.setIcon({path: 'icon-on.png'});
41+
chrome.action.setTitle({title: 'DataChartRenderer - enabled'});
42+
}
43+
44+
function disable() {
45+
console.log("bg disable");
46+
enabled = false;
47+
chrome.tabs.query({active: true, currentWindow: true}, function(tabs){
48+
chrome.tabs.sendMessage(tabs[0].id, {message: 'dcr-disable'});
49+
});
50+
chrome.action.setIcon({path: 'icon-off.png'});
51+
chrome.action.setTitle({title: 'DataChartRenderer - disabled'});
652
}

extension/bckp.js

Lines changed: 0 additions & 64 deletions
This file was deleted.

extension/content/main.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,12 @@
22
let enabled = true;
33
let limit = 5000;
44
chrome.runtime.onMessage.addListener(
5-
function (request) {
5+
function (request, sender, sendResponse) {
66
if (request.message === "dcr-enable") {
77
enabled = true;
8-
window.hardRowLimit = +request.limit;
9-
console.log("DCR Enabled with limit ", request.limit);
108
}
119
else if (request.message === "dcr-disable") {
1210
enabled = false;
13-
console.log("DCR Stop");
1411
}
1512
}
1613
);

extension/favicon.ico

-2.64 KB
Binary file not shown.

extension/manifest.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,8 @@
33
"version": "0.0.1",
44
"manifest_version": 3,
55
"description": "This extension dynamically rendering potential chart representations of found CSV files in a popup.",
6-
"icons": { "32": "favicon.ico"},
7-
"action": {
8-
"default_popup": "popup/popup.html",
9-
"default_icon": "icon-on.png"
10-
},
6+
"icons": { "32": "icon-on.png"},
7+
"action": {},
118
"content_scripts": [
129
{
1310
"matches": [
@@ -26,6 +23,9 @@
2623
"run_at": "document_end"
2724
}
2825
],
26+
"background": {
27+
"service_worker": "background.js"
28+
},
2929
"permissions": [
3030
"activeTab",
3131
"scripting",

extension/popup/popup.html

Lines changed: 0 additions & 12 deletions
This file was deleted.

extension/popup/popup.js

Lines changed: 0 additions & 56 deletions
This file was deleted.

0 commit comments

Comments
 (0)