-
Notifications
You must be signed in to change notification settings - Fork 74
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
eded5a0
commit a3bf804
Showing
26 changed files
with
287 additions
and
222 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
name: 🚀 Deploy the website index | ||
|
||
on: | ||
workflow_dispatch: {} | ||
push: | ||
branches: [rewrite] #[master, main] # TODO: change this | ||
tags-ignore: ['**'] | ||
paths: [website/index/**, .github/workflows/deploy-website-index.yml] | ||
|
||
concurrency: | ||
group: ${{ github.ref }}-website-index | ||
cancel-in-progress: true | ||
|
||
jobs: | ||
publish: | ||
name: 🚀 Publish the site | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- uses: cloudflare/wrangler-action@v3 | ||
env: {PROJECT_NAME: random-user-agent-index, DIST_DIR: ./website/index} | ||
with: | ||
apiToken: ${{ secrets.CLOUDFLARE_PAGES_DEPLOY_TOKEN }} | ||
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} | ||
environment: main # aka CF "production" environment | ||
command: pages deploy ${{ env.DIST_DIR }} --project-name=${{ env.PROJECT_NAME }} --commit-dirty=true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
name: 🚀 Deploy the sandbox website | ||
|
||
on: | ||
workflow_dispatch: {} | ||
push: | ||
branches: [rewrite] #[master, main] # TODO: change this | ||
tags-ignore: ['**'] | ||
paths: [website/sandbox/**, .github/workflows/deploy-website-sandbox.yml] | ||
|
||
concurrency: | ||
group: ${{ github.ref }}-sandbox-website | ||
cancel-in-progress: true | ||
|
||
jobs: | ||
publish: | ||
name: 🚀 Publish the site | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- uses: cloudflare/wrangler-action@v3 | ||
env: {PROJECT_NAME: random-user-agent-ua-test-sandbox, DIST_DIR: ./website/sandbox} | ||
with: | ||
apiToken: ${{ secrets.CLOUDFLARE_PAGES_DEPLOY_TOKEN }} | ||
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} | ||
environment: main # aka CF "production" environment | ||
command: pages deploy ${{ env.DIST_DIR }} --project-name=${{ env.PROJECT_NAME }} --commit-dirty=true |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
export { isApplicableForDomain, reloadRequestHeaders } from './filters' | ||
export { isApplicableForDomain, reloadRequestHeadersAndBridge } from './filters' | ||
export { default as renewUserAgent } from './renew-user-agent' | ||
export { default as updateRemoteUserAgentList } from './update-remote-useragent-list' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
import type { ContentScriptPayload, ReadonlyUserAgentState } from '~/shared/types' | ||
import { browserBrands, isMobile, platform } from '~/shared/client-hint' | ||
|
||
/** | ||
* Sets the bridge data to the local storage, which will be used by the content script. In fact, it enables the | ||
* javascript protection. | ||
*/ | ||
export const setBridgeData = async ( | ||
ua: ReadonlyUserAgentState, | ||
filter?: { applyToDomains?: ReadonlyArray<string>; exceptDomains?: ReadonlyArray<string> } | ||
): Promise<ContentScriptPayload> => { | ||
const payload: ContentScriptPayload = { | ||
current: ua, | ||
brands: { | ||
major: (() => { | ||
switch (ua.browser) { | ||
case 'chrome': | ||
return browserBrands('chrome', ua.version.browser.major) | ||
case 'opera': | ||
return browserBrands('opera', ua.version.browser.major, ua.version.underHood?.major || 0) | ||
case 'edge': | ||
return browserBrands('edge', ua.version.browser.major, ua.version.underHood?.major || 0) | ||
} | ||
|
||
return [] | ||
})(), | ||
full: (() => { | ||
switch (ua.browser) { | ||
case 'chrome': | ||
return browserBrands('chrome', ua.version.browser.full) | ||
case 'opera': | ||
return browserBrands('opera', ua.version.browser.full, ua.version.underHood?.full || '') | ||
case 'edge': | ||
return browserBrands('edge', ua.version.browser.full, ua.version.underHood?.full || '') | ||
} | ||
|
||
return [] | ||
})(), | ||
}, | ||
platform: platform(ua.os), | ||
isMobile: isMobile(ua.os), | ||
filtering: { | ||
applyToDomains: filter?.applyToDomains || [], | ||
exceptDomains: filter?.exceptDomains || [], | ||
}, | ||
} | ||
|
||
await chrome.storage.local.set({ [__UNIQUE_PAYLOAD_KEY_NAME__]: payload }) | ||
|
||
if (chrome.runtime.lastError) { | ||
throw new Error(chrome.runtime.lastError.message) | ||
} | ||
|
||
return payload | ||
} | ||
|
||
/** Unsets the bridge data from the local storage. In fact, it disables the javascript protection. */ | ||
export const unsetBridgeData = async (): Promise<void> => { | ||
await chrome.storage.local.remove([__UNIQUE_PAYLOAD_KEY_NAME__]) | ||
|
||
if (chrome.runtime.lastError) { | ||
throw new Error(chrome.runtime.lastError.message) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
export { setRequestHeaders, unsetRequestHeaders } from './http-requests' | ||
export { setBridgeData, unsetBridgeData } from './content-script-bridge' |
Oops, something went wrong.