- chrome.action.onClicked.addListener(function (tab) {
- chrome.tabs.create({url: 'https://token.oaifree.com/auth'});
- });
- chrome.webRequest.onBeforeRedirect.addListener(
- function (details) {
- if (details.redirectUrl.startsWith('com.openai.chat://auth0.openai.com/ios/com.openai.chat/callback?')) {
- const state = new URL(details.redirectUrl).searchParams.get('state');
- if (!state.startsWith('ofstate:')) {
- return;
- }
- chrome.storage.local.set({url: details.redirectUrl}, function () {
- chrome.tabs.update(details.tabId, {url: 'auth.html'});
- });
- return {cancel: true};
- }
- },
- {urls: ["<all_urls>"]},
- ["responseHeaders"]