Skip to content

Commit b370d81

Browse files
committed
remove webrequest and webrequestBlocking
1 parent 704ce76 commit b370d81

9 files changed

Lines changed: 16 additions & 157 deletions

File tree

app/_locales/i18n-keys.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +0,0 @@
1-
"use strict";
2-
Object.defineProperty(exports, "__esModule", { value: true });

app/js/background/crm.ts

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -944,18 +944,6 @@ export namespace CRMNodes.Script.Updating {
944944
});
945945
}
946946

947-
(anonymousLibs as {
948-
url: string;
949-
name: null;
950-
}[]).forEach(anonymousLib => {
951-
modules.Resources.Anonymous.handle({
952-
type: 'register',
953-
name: anonymousLib.url,
954-
url: anonymousLib.url,
955-
scriptId: scriptNode.id
956-
});
957-
});
958-
959947
const { libraries } = await browserAPI.storage.local.get('libraries');
960948

961949
//Install all libraries
@@ -1128,22 +1116,6 @@ export namespace CRMNodes.Script.Updating {
11281116
//Allowed permissions
11291117
node.permissions = allowedPermissions || [];
11301118

1131-
//Resources
1132-
if (metaTags['resource']) {
1133-
//Register resources
1134-
const resources: string[] = metaTags['resource'];
1135-
resources.forEach(resource => {
1136-
const resourceSplit = resource.split(/(\s*)/);
1137-
const [resourceName, resourceUrl] = resourceSplit;
1138-
modules.Resources.Resource.handle({
1139-
type: 'register',
1140-
name: resourceName,
1141-
url: resourceUrl,
1142-
scriptId: node.id as CRM.NodeId<CRM.ScriptNode>
1143-
});
1144-
});
1145-
}
1146-
11471119
const { requestPermissions = [] } = await browserAPI.storage.local.get<CRM.StorageLocal>();
11481120
const allPermissions = browserAPI.permissions ? await browserAPI.permissions.getAll() : {
11491121
permissions: []

app/js/background/global-declarations.ts

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -667,17 +667,6 @@ export namespace GlobalDeclarations {
667667
});
668668
}
669669

670-
function setupResourceProxy() {
671-
browserAPI.webRequest.onBeforeRequest.addListener((details) => {
672-
window.info('Redirecting', details);
673-
return {
674-
redirectUrl: `${location.protocol}//${browserAPI.runtime.id}/fonts/fonts.css`
675-
}
676-
}, {
677-
urls: ['*://fonts.googleapis.com/', '*://fonts.gstatic.com/']
678-
});
679-
}
680-
681670
function onTabUpdated(_id: TabId, changeInfo: {
682671
status?: 'loading'|'complete';
683672
url?: string;
@@ -807,20 +796,8 @@ export namespace GlobalDeclarations {
807796
browserAPI.tabs.onUpdated.addListener(onTabUpdated);
808797
browserAPI.tabs.onRemoved.addListener(onTabsRemoved);
809798
browserAPI.tabs.onHighlighted && browserAPI.tabs.onHighlighted.addListener(tabChangeListener);
810-
browserAPI.webRequest.onBeforeRequest.addListener((details) => {
811-
const split = details.url
812-
.split(`https://www.localhost.io/resource/`)[1].split('/');
813-
const name = split[0];
814-
const scriptId = ~~split[1] as CRM.NodeId<CRM.ScriptNode>;
815-
return {
816-
redirectUrl: getResourceData(name, scriptId)
817-
};
818-
}, {
819-
urls: [`https://www.localhost.io/resource/*`]
820-
}, ['blocking']);
821799
listenNotifications();
822800
listenKeyCommands();
823-
setupResourceProxy();
824801
}
825802

826803
export function runAlwaysRunNodes(tab: _browser.tabs.Tab) {

app/js/background/resources.ts

Lines changed: 0 additions & 86 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,6 @@ export namespace Resources {
4040
scriptId: CRM.NodeId<CRM.ScriptNode>;
4141
}, name: string) {
4242
switch (message.type) {
43-
case 'register':
44-
registerResource(name, message.url, message.scriptId);
45-
break;
4643
case 'remove':
4744
removeResource(name, message.scriptId);
4845
break;
@@ -56,50 +53,6 @@ export namespace Resources {
5653
}
5754
}
5855

59-
function getUrlData(scriptId: CRM.NodeId<CRM.ScriptNode>, url: string, callback: (dataURI: string,
60-
dataString: string) => void) {
61-
//First check if the data has already been fetched
62-
if (modules.storages.urlDataPairs.get(url)) {
63-
const dataPairs = modules.storages.urlDataPairs.get(url);
64-
if (dataPairs.refs.indexOf(scriptId) === -1) {
65-
dataPairs.refs.push(scriptId);
66-
}
67-
callback(dataPairs.dataURI, dataPairs.dataString);
68-
} else {
69-
modules.Util.convertFileToDataURI(url, (dataURI, dataString) => {
70-
//Write the data away to the url-data-pairs object
71-
modules.storages.urlDataPairs.set(url, {
72-
dataURI: dataURI,
73-
dataString: dataString,
74-
refs: [scriptId]
75-
});
76-
callback(dataURI, dataString);
77-
});
78-
}
79-
}
80-
function getHashes(url: string): {
81-
algorithm: string;
82-
hash: string;
83-
}[] {
84-
const hashes: {
85-
algorithm: string;
86-
hash: string;
87-
}[] = [];
88-
const hashString = url.split('#')[1];
89-
if (!hashString) {
90-
return [];
91-
}
92-
93-
const hashStrings = hashString.split(/[,|;]/g);
94-
hashStrings.forEach((hash) => {
95-
const split = hash.split('=');
96-
hashes.push({
97-
algorithm: split[0],
98-
hash: split[1]
99-
});
100-
});
101-
return hashes;
102-
}
10356
function doAlgorithm(name: string, data: any, lastMatchingHash: {
10457
algorithm: string;
10558
hash: string;
@@ -161,45 +114,6 @@ export namespace Resources {
161114
}
162115
return false;
163116
}
164-
function registerResource(name: string, url: string, scriptId: CRM.NodeId<CRM.ScriptNode>) {
165-
const registerHashes = getHashes(url);
166-
if (window.navigator.onLine) {
167-
getUrlData(scriptId, url, (dataURI, dataString) => {
168-
const resources = modules.storages.resources;
169-
modules.Util.setMapDefault(resources, scriptId, {});
170-
resources.get(scriptId)[name] = {
171-
name: name,
172-
sourceUrl: url,
173-
dataURI: dataURI,
174-
dataString: dataString,
175-
hashes: registerHashes,
176-
matchesHashes: matchesHashes(registerHashes, dataString),
177-
crmUrl: `https://www.localhost.io/resource/${scriptId}/${name}`
178-
};
179-
browserAPI.storage.local.set({
180-
resources: modules.Util.fromMap(resources),
181-
urlDataPairs: modules.Util.fromMap(modules.storages.urlDataPairs)
182-
});
183-
});
184-
}
185-
186-
const resourceKeys = modules.storages.resourceKeys;
187-
for (const resourceKey of resourceKeys) {
188-
if (resourceKey.name === name &&
189-
resourceKey.scriptId === scriptId) {
190-
return;
191-
}
192-
}
193-
resourceKeys.push({
194-
name: name,
195-
sourceUrl: url,
196-
hashes: registerHashes,
197-
scriptId: scriptId
198-
});
199-
browserAPI.storage.local.set({
200-
resourceKeys: resourceKeys
201-
});
202-
}
203117
function removeResource(name: string, scriptId: CRM.NodeId<CRM.ScriptNode>) {
204118
for (let i = 0; i < modules.storages.resourceKeys.length; i++) {
205119
if (modules.storages.resourceKeys[i].name === name &&

app/manifest.chrome.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,7 @@
4343
"contextMenus",
4444
"storage",
4545
"tabs",
46-
"unlimitedStorage",
47-
"webRequest",
48-
"webRequestBlocking"
46+
"unlimitedStorage"
4947
],
5048

5149
"web_accessible_resources": [
@@ -83,7 +81,9 @@
8381
"topSites",
8482
"tabCapture",
8583
"tts",
86-
"webNavigation"
84+
"webNavigation",
85+
"webRequest",
86+
"webRequestBlocking"
8787
],
8888

8989
"commands": {

app/manifest.edge.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,7 @@
4444
"contextMenus",
4545
"storage",
4646
"tabs",
47-
"unlimitedStorage",
48-
"webRequest",
49-
"webRequestBlocking"
47+
"unlimitedStorage"
5048
],
5149

5250
"web_accessible_resources": [
@@ -84,7 +82,9 @@
8482
"topSites",
8583
"tabCapture",
8684
"tts",
87-
"webNavigation"
85+
"webNavigation",
86+
"webRequest",
87+
"webRequestBlocking"
8888
],
8989

9090
"commands": {

app/manifest.firefox.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,7 @@
5151
"contextMenus",
5252
"storage",
5353
"tabs",
54-
"unlimitedStorage",
55-
"webRequest",
56-
"webRequestBlocking"
54+
"unlimitedStorage"
5755
],
5856

5957
"web_accessible_resources": [
@@ -73,7 +71,9 @@
7371
"management",
7472
"notifications",
7573
"topSites",
76-
"webNavigation"
74+
"webNavigation",
75+
"webRequest",
76+
"webRequestBlocking"
7777
],
7878

7979
"commands": {

app/manifest.opera.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,7 @@
4343
"contextMenus",
4444
"storage",
4545
"tabs",
46-
"unlimitedStorage",
47-
"webRequest",
48-
"webRequestBlocking"
46+
"unlimitedStorage"
4947
],
5048

5149
"web_accessible_resources": [
@@ -82,7 +80,9 @@
8280
"topSites",
8381
"tabCapture",
8482
"tts",
85-
"webNavigation"
83+
"webNavigation",
84+
"webRequest",
85+
"webRequestBlocking"
8686
],
8787

8888
"commands": {

test/UI/browser-api-dummy.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1242,8 +1242,6 @@ testWindow.chrome = {
12421242
"activeTab",
12431243
"notifications",
12441244
"storage",
1245-
"webRequest",
1246-
"webRequestBlocking",
12471245
"contextMenus",
12481246
"unlimitedStorage"
12491247
]

0 commit comments

Comments
 (0)