jumpy-lion 0.0.34 → 0.0.35

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,255 +1,249 @@
1
- var app = {};
2
- app.error = function () {
3
- return chrome.runtime.lastError;
4
- };
5
- app.name = function () {
6
- return chrome.runtime.getManifest().name;
7
- };
8
- app.notifications = {
9
- "create": function (e, callback) {
10
- if (chrome.notifications) {
11
- chrome.notifications.create(app.notifications.id, {
12
- "type": e.type ? e.type : "basic",
13
- "message": e.message ? e.message : '',
14
- "title": e.title ? e.title : "Notifications",
15
- "iconUrl": e.iconUrl ? chrome.runtime.getURL(e.iconUrl) : chrome.runtime.getURL("data/icons/64.png")
16
- }, function (e) {
17
- if (callback)
18
- callback(e);
19
- });
20
- }
21
- }
22
- };
23
- app.popup = {
24
- "port": null,
25
- "message": {},
26
- "receive": function (id, callback) {
27
- if (id) {
28
- app.popup.message[id] = callback;
29
- }
30
- },
31
- "send": function (id, data) {
32
- if (id) {
33
- chrome.runtime.sendMessage({ "data": data, "method": id, "path": "background-to-popup" }, app.error);
34
- }
35
- },
36
- "post": function (id, data) {
37
- if (id) {
38
- if (app.popup.port) {
39
- app.popup.port.postMessage({ "data": data, "method": id, "path": "background-to-popup" });
40
- }
41
- }
42
- }
43
- };
44
- app.contextmenu = {
45
- "create": function (options, callback) {
46
- if (chrome.contextMenus) {
47
- chrome.contextMenus.create(options, function (e) {
48
- if (callback)
49
- callback(e);
50
- });
51
- }
52
- },
53
- "update": function (id, options, callback) {
54
- if (chrome.contextMenus) {
55
- chrome.contextMenus.update(id, options, function (e) {
56
- if (callback)
57
- callback(e);
58
- });
59
- }
60
- },
61
- "on": {
62
- "clicked": function (callback) {
63
- if (chrome.contextMenus) {
64
- chrome.contextMenus.onClicked.addListener(function (info, tab) {
65
- app.storage.load(function () {
66
- callback(info, tab);
67
- });
68
- });
69
- }
70
- }
71
- }
72
- };
73
- app.tab = {
74
- "query": {
75
- "index": function (callback) {
76
- chrome.tabs.query({ "active": true, "currentWindow": true }, function (tabs) {
77
- let tmp = chrome.runtime.lastError;
78
- if (tabs && tabs.length) {
79
- callback(tabs[0].index);
80
- }
81
- else
82
- callback(undefined);
83
- });
84
- }
85
- },
86
- "open": function (url, index, active, callback) {
87
- const properties = {
88
- "url": url,
89
- "active": active !== undefined ? active : true
90
- };
91
- /* */
92
- if (index !== undefined) {
93
- if (typeof index === "number") {
94
- properties.index = index + 1;
95
- }
96
- }
97
- /* */
98
- chrome.tabs.create(properties, function (tab) {
99
- if (callback)
100
- callback(tab);
101
- });
102
- }
103
- };
104
- app.storage = {
105
- "local": {},
106
- "read": function (id) {
107
- return app.storage.local[id];
108
- },
109
- "update": function (callback) {
110
- if (app.session)
111
- app.session.load();
112
- /* */
113
- chrome.storage.local.get(null, function (e) {
114
- app.storage.local = e;
115
- if (callback) {
116
- callback("update");
117
- }
118
- });
119
- },
120
- "write": function (id, data, callback) {
121
- let tmp = {};
122
- tmp[id] = data;
123
- app.storage.local[id] = data;
124
- /* */
125
- chrome.storage.local.set(tmp, function (e) {
126
- if (callback) {
127
- callback(e);
128
- }
129
- });
130
- },
131
- "load": function (callback) {
132
- const keys = Object.keys(app.storage.local);
133
- if (keys && keys.length) {
134
- if (callback) {
135
- callback("cache");
136
- }
137
- }
138
- else {
139
- app.storage.update(function () {
140
- if (callback)
141
- callback("disk");
142
- });
143
- }
144
- }
145
- };
146
- app.on = {
147
- "management": function (callback) {
148
- chrome.management.getSelf(callback);
149
- },
150
- "uninstalled": function (url) {
151
- chrome.runtime.setUninstallURL(url, function () { });
152
- },
153
- "installed": function (callback) {
154
- chrome.runtime.onInstalled.addListener(function (e) {
155
- app.storage.load(function () {
156
- callback(e);
157
- });
158
- });
159
- },
160
- "startup": function (callback) {
161
- chrome.runtime.onStartup.addListener(function (e) {
162
- app.storage.load(function () {
163
- callback(e);
164
- });
165
- });
166
- },
167
- "connect": function (callback) {
168
- chrome.runtime.onConnect.addListener(function (e) {
169
- app.storage.load(function () {
170
- if (callback)
171
- callback(e);
172
- });
173
- });
174
- },
175
- "storage": function (callback) {
176
- chrome.storage.onChanged.addListener(function (changes, namespace) {
177
- app.storage.update(function () {
178
- if (callback) {
179
- callback(changes, namespace);
180
- }
181
- });
182
- });
183
- },
184
- "message": function (callback) {
185
- chrome.runtime.onMessage.addListener(function (request, sender, sendResponse) {
186
- app.storage.load(function () {
187
- callback(request, sender, sendResponse);
188
- });
189
- /* */
190
- return true;
191
- });
192
- }
193
- };
194
- app.page = {
195
- "port": null,
196
- "message": {},
197
- "sender": {
198
- "port": {}
199
- },
200
- "receive": function (id, callback) {
201
- if (id) {
202
- app.page.message[id] = callback;
203
- }
204
- },
205
- "post": function (id, data, tabId) {
206
- if (id) {
207
- if (tabId) {
208
- if (app.page.sender.port[tabId]) {
209
- app.page.sender.port[tabId].postMessage({ "data": data, "method": id, "path": "background-to-page" });
210
- }
211
- }
212
- else if (app.page.port) {
213
- app.page.port.postMessage({ "data": data, "method": id, "path": "background-to-page" });
214
- }
215
- }
216
- },
217
- "send": function (id, data, tabId, frameId) {
218
- if (id) {
219
- chrome.tabs.query({}, function (tabs) {
220
- let tmp = chrome.runtime.lastError;
221
- if (tabs && tabs.length) {
222
- const message = {
223
- "method": id,
224
- "data": data ? data : {},
225
- "path": "background-to-page"
226
- };
227
- /* */
228
- tabs.forEach(function (tab) {
229
- if (tab) {
230
- message.data.tabId = tab.id;
231
- message.data.top = tab.url ? tab.url : '';
232
- message.data.title = tab.title ? tab.title : '';
233
- /* */
234
- if (tabId !== null && tabId !== undefined) {
235
- if (tabId === tab.id) {
236
- if (frameId !== null && frameId !== undefined) {
237
- chrome.tabs.sendMessage(tab.id, message, { "frameId": frameId }, app.error);
238
- }
239
- else {
240
- chrome.tabs.sendMessage(tab.id, message, app.error);
241
- }
242
- }
243
- }
244
- else {
245
- chrome.tabs.sendMessage(tab.id, message, app.error);
246
- }
247
- }
248
- });
249
- }
250
- });
251
- }
252
- }
253
- };
254
- export {};
255
- //# sourceMappingURL=chrome.js.map
1
+ var app = {};
2
+
3
+ app.error = function () {
4
+ return chrome.runtime.lastError;
5
+ };
6
+
7
+ app.name = function () {
8
+ return chrome.runtime.getManifest().name;
9
+ };
10
+
11
+ app.notifications = {
12
+ "create": function (e, callback) {
13
+ if (chrome.notifications) {
14
+ chrome.notifications.create(app.notifications.id, {
15
+ "type": e.type ? e.type : "basic",
16
+ "message": e.message ? e.message : '',
17
+ "title": e.title ? e.title : "Notifications",
18
+ "iconUrl": e.iconUrl ? chrome.runtime.getURL(e.iconUrl) : chrome.runtime.getURL("data/icons/64.png")
19
+ }, function (e) {
20
+ if (callback) callback(e);
21
+ });
22
+ }
23
+ }
24
+ };
25
+
26
+ app.popup = {
27
+ "port": null,
28
+ "message": {},
29
+ "receive": function (id, callback) {
30
+ if (id) {
31
+ app.popup.message[id] = callback;
32
+ }
33
+ },
34
+ "send": function (id, data) {
35
+ if (id) {
36
+ chrome.runtime.sendMessage({"data": data, "method": id, "path": "background-to-popup"}, app.error);
37
+ }
38
+ },
39
+ "post": function (id, data) {
40
+ if (id) {
41
+ if (app.popup.port) {
42
+ app.popup.port.postMessage({"data": data, "method": id, "path": "background-to-popup"});
43
+ }
44
+ }
45
+ }
46
+ };
47
+
48
+ app.contextmenu = {
49
+ "create": function (options, callback) {
50
+ if (chrome.contextMenus) {
51
+ chrome.contextMenus.create(options, function (e) {
52
+ if (callback) callback(e);
53
+ });
54
+ }
55
+ },
56
+ "update": function (id, options, callback) {
57
+ if (chrome.contextMenus) {
58
+ chrome.contextMenus.update(id, options, function (e) {
59
+ if (callback) callback(e);
60
+ });
61
+ }
62
+ },
63
+ "on": {
64
+ "clicked": function (callback) {
65
+ if (chrome.contextMenus) {
66
+ chrome.contextMenus.onClicked.addListener(function (info, tab) {
67
+ app.storage.load(function () {
68
+ callback(info, tab);
69
+ });
70
+ });
71
+ }
72
+ }
73
+ }
74
+ };
75
+
76
+ app.tab = {
77
+ "query": {
78
+ "index": function (callback) {
79
+ chrome.tabs.query({"active": true, "currentWindow": true}, function (tabs) {
80
+ let tmp = chrome.runtime.lastError;
81
+ if (tabs && tabs.length) {
82
+ callback(tabs[0].index);
83
+ } else callback(undefined);
84
+ });
85
+ }
86
+ },
87
+ "open": function (url, index, active, callback) {
88
+ const properties = {
89
+ "url": url,
90
+ "active": active !== undefined ? active : true
91
+ };
92
+ /* */
93
+ if (index !== undefined) {
94
+ if (typeof index === "number") {
95
+ properties.index = index + 1;
96
+ }
97
+ }
98
+ /* */
99
+ chrome.tabs.create(properties, function (tab) {
100
+ if (callback) callback(tab);
101
+ });
102
+ }
103
+ };
104
+
105
+ app.storage = {
106
+ "local": {},
107
+ "read": function (id) {
108
+ return app.storage.local[id];
109
+ },
110
+ "update": function (callback) {
111
+ if (app.session) app.session.load();
112
+ /* */
113
+ chrome.storage.local.get(null, function (e) {
114
+ app.storage.local = e;
115
+ if (callback) {
116
+ callback("update");
117
+ }
118
+ });
119
+ },
120
+ "write": function (id, data, callback) {
121
+ let tmp = {};
122
+ tmp[id] = data;
123
+ app.storage.local[id] = data;
124
+ /* */
125
+ chrome.storage.local.set(tmp, function (e) {
126
+ if (callback) {
127
+ callback(e);
128
+ }
129
+ });
130
+ },
131
+ "load": function (callback) {
132
+ const keys = Object.keys(app.storage.local);
133
+ if (keys && keys.length) {
134
+ if (callback) {
135
+ callback("cache");
136
+ }
137
+ } else {
138
+ app.storage.update(function () {
139
+ if (callback) callback("disk");
140
+ });
141
+ }
142
+ }
143
+ };
144
+
145
+ app.on = {
146
+ "management": function (callback) {
147
+ chrome.management.getSelf(callback);
148
+ },
149
+ "uninstalled": function (url) {
150
+ chrome.runtime.setUninstallURL(url, function () {});
151
+ },
152
+ "installed": function (callback) {
153
+ chrome.runtime.onInstalled.addListener(function (e) {
154
+ app.storage.load(function () {
155
+ callback(e);
156
+ });
157
+ });
158
+ },
159
+ "startup": function (callback) {
160
+ chrome.runtime.onStartup.addListener(function (e) {
161
+ app.storage.load(function () {
162
+ callback(e);
163
+ });
164
+ });
165
+ },
166
+ "connect": function (callback) {
167
+ chrome.runtime.onConnect.addListener(function (e) {
168
+ app.storage.load(function () {
169
+ if (callback) callback(e);
170
+ });
171
+ });
172
+ },
173
+ "storage": function (callback) {
174
+ chrome.storage.onChanged.addListener(function (changes, namespace) {
175
+ app.storage.update(function () {
176
+ if (callback) {
177
+ callback(changes, namespace);
178
+ }
179
+ });
180
+ });
181
+ },
182
+ "message": function (callback) {
183
+ chrome.runtime.onMessage.addListener(function (request, sender, sendResponse) {
184
+ app.storage.load(function () {
185
+ callback(request, sender, sendResponse);
186
+ });
187
+ /* */
188
+ return true;
189
+ });
190
+ }
191
+ };
192
+
193
+ app.page = {
194
+ "port": null,
195
+ "message": {},
196
+ "sender": {
197
+ "port": {}
198
+ },
199
+ "receive": function (id, callback) {
200
+ if (id) {
201
+ app.page.message[id] = callback;
202
+ }
203
+ },
204
+ "post": function (id, data, tabId) {
205
+ if (id) {
206
+ if (tabId) {
207
+ if (app.page.sender.port[tabId]) {
208
+ app.page.sender.port[tabId].postMessage({"data": data, "method": id, "path": "background-to-page"});
209
+ }
210
+ } else if (app.page.port) {
211
+ app.page.port.postMessage({"data": data, "method": id, "path": "background-to-page"});
212
+ }
213
+ }
214
+ },
215
+ "send": function (id, data, tabId, frameId) {
216
+ if (id) {
217
+ chrome.tabs.query({}, function (tabs) {
218
+ let tmp = chrome.runtime.lastError;
219
+ if (tabs && tabs.length) {
220
+ const message = {
221
+ "method": id,
222
+ "data": data ? data : {},
223
+ "path": "background-to-page"
224
+ };
225
+ /* */
226
+ tabs.forEach(function (tab) {
227
+ if (tab) {
228
+ message.data.tabId = tab.id;
229
+ message.data.top = tab.url ? tab.url : '';
230
+ message.data.title = tab.title ? tab.title : '';
231
+ /* */
232
+ if (tabId !== null && tabId !== undefined) {
233
+ if (tabId === tab.id) {
234
+ if (frameId !== null && frameId !== undefined) {
235
+ chrome.tabs.sendMessage(tab.id, message, {"frameId": frameId}, app.error);
236
+ } else {
237
+ chrome.tabs.sendMessage(tab.id, message, app.error);
238
+ }
239
+ }
240
+ } else {
241
+ chrome.tabs.sendMessage(tab.id, message, app.error);
242
+ }
243
+ }
244
+ });
245
+ }
246
+ });
247
+ }
248
+ }
249
+ };