Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions chrome-extension/background/background.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,8 @@ export class App {
await AuthContext.init(new LocalStorageJsonStorage());
app.api.authContext.init('accountId');
console.debug('[APP] Auth Context loaded');
console.log(`[APP] network status ${window.navigator.onLine ? 'online' : 'offline'}`);
if (!this.state.currentUser && window.navigator.onLine) {
console.log(`[APP] network status ${globalThis.navigator.onLine ? 'online' : 'offline'}`);
if (!this.state.currentUser && globalThis.navigator.onLine) {
await app.run(GetCurrentUserBackgroundJob);
}
app.api.onError.subscribe(e => {
Expand Down
11 changes: 10 additions & 1 deletion chrome-extension/background/utils/local-storage.proxy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,15 @@ function loadStoredValues (key, value, exclude: string[]) {
}
}

function storeValues (key, values) {
try {
localStorage.setItem(key, JSON.stringify(values));
} catch (e) {
console.warn(e);
}

}

export function localStorageProxy<T extends Object> (storageKey, value, exclude: string[]): T {
console.debug('[localStorageProxy] start ', deepClone(value));

Expand All @@ -22,7 +31,7 @@ export function localStorageProxy<T extends Object> (storageKey, value, exclude:

const original = deepClone(value);
let timeoutID;
const save = () => localStorage.setItem(storageKey, JSON.stringify(original));
const save = () => storeValues(storageKey, original);
const getter = key => () => original[key];
const setter = key => value => {
original[key] = value;
Expand Down
7 changes: 3 additions & 4 deletions chrome-extension/background/utils/notifications.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,13 @@ import uuid from 'uuid';

export function notify (title, message, id?) {
id = id || uuid.v4();
const opt = {

chrome.notifications.create(id, {
type: 'basic',
title: title,
message: message,
iconUrl: 'img/icon/icon-64.png'
};

chrome.notifications.create(id, opt);
});
}

export function notifyError (e: Error) {
Expand Down
2 changes: 1 addition & 1 deletion chrome-extension/common/initSentry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export function InitSentry (whereTag, listenStateFromBackground: boolean = false
beforeSend (event, hint?) {
if (hint
&& hint.originalException
&& !window.navigator.onLine
&& !globalThis.navigator.onLine
&& typeof hint.originalException === 'object'
&& hint.originalException.message === 'Network error: Failed to fetch') {
return null;
Expand Down
20 changes: 7 additions & 13 deletions chrome-extension/manifest.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"manifest_version": 2,
"manifest_version": 3,
"name": "Appodeal",
"short_name": "Appodeal Admob Sync",
"description": "This extension will create and sync Appodeal adunits in your Admob account.",
"minimum_chrome_version": "62",
"version": "20.02.00",
"browser_action": {
"version": "20.03.00",
"action": {
"default_icon": {
"16": "img/icon/icon-16.png"
},
Expand Down Expand Up @@ -58,22 +58,16 @@
}
],
"background": {
"scripts": [
"background.js"
],
"persistent": false
"service_worker": "background.js"
},
"web_accessible_resources": [
"img/*",
"js/vendor/*",
"js/helpers/*"
],
"permissions": [
"tabs",
"cookies",
"storage",
"notifications",
"identity",
"identity"
],
"host_permissions": [
"*://*.appodeal.com/*",
"*://*.admob.com/*"
],
Expand Down
12 changes: 10 additions & 2 deletions chrome-extension/popup/utils/popupClickHandlers.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import {Actions, TabJobs} from '../../common/actions';


const ADMOB_HOME = 'https://apps.admob.com/logout?continue=https://apps.admob.com/';
const ADMOB_HOME_WITH_RELOGIN = 'https://apps.admob.com/logout?continue=https://apps.admob.com/';
const ADMOB_ACCOUNT_ADD_OR_RECONNECT = 'https://app.appodeal.com/apps/linked_networks#AddAdmobAccount';
const ADMOB_HOME = 'https://apps.admob.com/v2/home';
const ADMOB_DASHBOARD_ROOT = 'https://apps.admob.com/';

async function navigateCurrentTab (url: string): Promise<chrome.tabs.Tab> {
return new Promise(resolve => {
Expand Down Expand Up @@ -38,7 +40,13 @@ export async function onClickStartAdmobAccountSetup () {


export async function startSyncAdmobAccount () {
const tab = await navigateCurrentTab(ADMOB_HOME);
const tabs = await chrome.tabs.query({active: true, currentWindow: true});
const tab = tabs[0];
if (tab.url && tab.url.startsWith(ADMOB_DASHBOARD_ROOT)) {
await chrome.tabs.update(tab.id, {url: ADMOB_HOME});
} else {
await chrome.tabs.update(tab.id, {url: ADMOB_HOME_WITH_RELOGIN});
}
await setCurrentJob(TabJobs.syncAdunits, tab.id);
}

Expand Down
Loading