-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcors-extension
More file actions
71 lines (39 loc) · 2.15 KB
/
cors-extension
File metadata and controls
71 lines (39 loc) · 2.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
// manifest.json - chrome
{
"manifest_version" : 3,
"name" : "cors",
"version" : "1.0.0",
"icons" : {"48":"asterisk.png"},
"background" : {"service_worker":"extension.js"},
"permissions" : ["declarativeNetRequest"],
"host_permissions" : ["<all_urls>"]
}
// manifest.json - firefox
{
"manifest_version" : 3,
"name" : "cors",
"version" : "1",
"icons" : {"48":"asterisk.png"},
"permissions" : ["declarativeNetRequest"],
"background" : {"scripts":["extension.js"]},
"action" : {"default_icon":"asterisk.png"},
"host_permissions" : ["<all_urls>"]
}
// extension.js
if(typeof browser==='undefined'){
browser = chrome;
}
browser.runtime.onInstalled.addListener(()=>{
var rule = {
id: 1,
condition: {},
action: {
type: 'modifyHeaders',
responseHeaders: [
{header: 'access-control-allow-origin',operation:'set',value:'*'},
],
},
};
browser.declarativeNetRequest.updateDynamicRules({addRules:[rule],removeRuleIds:[rule.id]});
});
https://i.sstatic.net/1K0TZ8a3.png