-
-
Notifications
You must be signed in to change notification settings - Fork 31
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
Showing
32 changed files
with
808 additions
and
377 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
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
Large diffs are not rendered by default.
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
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
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 |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { Types } from "webextension-polyfill"; | ||
import store from "../../store"; | ||
|
||
export default function onProxySettingsChange( | ||
details: Types.SettingOnChangeDetailsType | ||
) { | ||
console.log(`⚙️ Proxy settings changed: ${details.levelOfControl}`); | ||
store.state.chromiumProxyActive = | ||
details.levelOfControl == "controlled_by_this_extension"; | ||
} |
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
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,18 +1,33 @@ | ||
import { Tabs } from "webextension-polyfill"; | ||
import findChannelFromTwitchTvUrl from "../../common/ts/findChannelFromTwitchTvUrl"; | ||
import getHostFromUrl from "../../common/ts/getHostFromUrl"; | ||
import isChannelWhitelisted from "../../common/ts/isChannelWhitelisted"; | ||
import isChromium from "../../common/ts/isChromium"; | ||
import { updateProxySettings } from "../../common/ts/proxySettings"; | ||
import { twitchTvHostRegex } from "../../common/ts/regexes"; | ||
import store from "../../store"; | ||
|
||
export default function onTabCreated(tab: Tabs.Tab): void { | ||
if (!tab.url || tab.id == null) return; | ||
const host = getHostFromUrl(tab.url); | ||
if (host != null && twitchTvHostRegex.test(host)) { | ||
const url = tab.url || tab.pendingUrl; | ||
if (!url) return; | ||
const host = getHostFromUrl(url); | ||
if (!host) return; | ||
|
||
// TODO: `twitchTvHostRegex` doesn't match `appeals.twitch.tv` and | ||
// `dashboard.twitch.tv` which means that passport requests from those | ||
// subdomains will not be proxied. This could mess up the cookie country. | ||
if (twitchTvHostRegex.test(host)) { | ||
console.log(`➕ Opened Twitch tab: ${tab.id}`); | ||
if (isChromium && store.state.openedTwitchTabs.length === 0) { | ||
updateProxySettings(); | ||
store.state.openedTwitchTabs.push(tab); | ||
|
||
if (isChromium) { | ||
const channelName = findChannelFromTwitchTvUrl(url); | ||
const isWhitelisted = channelName | ||
? isChannelWhitelisted(channelName) | ||
: false; | ||
if (!isWhitelisted && !store.state.chromiumProxyActive) { | ||
updateProxySettings(); | ||
} | ||
} | ||
store.state.openedTwitchTabs.push(tab.id); | ||
} | ||
} |
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
Oops, something went wrong.