Skip to content

Commit

Permalink
add x-frame-options blocking with declarative rules
Browse files Browse the repository at this point in the history
  • Loading branch information
r2dev2 committed Apr 1, 2024
1 parent e0d17cd commit 2e98faa
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 2 deletions.
19 changes: 19 additions & 0 deletions src/allow-iframe.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
[{
"id": 1,
"action": {
"type": "modifyHeaders",
"responseHeaders": [
{
"header": "X-Frame-Options",
"operation": "remove"
},
{
"header": "Frame-Options",
"operation": "remove"
}
]
},
"condition": {
"requestDomains": [ "youtube.com" ]
}
}]
9 changes: 8 additions & 1 deletion src/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"permissions": [
"storage",
"webRequest",
"webRequestBlocking"
"declarativeNetRequest"
],
"host_permissions": [
"https://www.youtube.com/*?*",
Expand Down Expand Up @@ -77,6 +77,13 @@
"{{firefox}}.background": {
"scripts": ["js/pages/background.js"]
},
"{{chrome}}.declarative_net_request": {
"rule_resources": [{
"id": "allow-iframe",
"enabled": true,
"path": "allow-iframe.json"
}]
},
"web_accessible_resources": [
{
"resources": [
Expand Down
13 changes: 12 additions & 1 deletion vite.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,16 @@ export default defineConfig({
}]
}),

// allow-iframe.json contains static DeclarativeNetHTTP rules
// for allowing iframing of ytc, need to manually copy over
copy({
hook: 'writeBundle',
targets: [{
src: path.resolve(__dirname, 'src/allow-iframe.json'),
dest: 'build/',
}]
}),

// include hyperchat's assets
copy({
hook: 'writeBundle',
Expand Down Expand Up @@ -147,7 +157,8 @@ export default defineConfig({
...jsEntry
],
watchFilePaths: [
path.resolve(__dirname, 'src/manifest.json')
path.resolve(__dirname, 'src/manifest.json'),
path.resolve(__dirname, 'src/allow-iframe.json')
],
webExtConfig: {
// lofi hip hop (the one that spawned after the og one ended)
Expand Down

0 comments on commit 2e98faa

Please sign in to comment.