Skip to content

Commit

Permalink
Release build 4.10.1 [ci release]
Browse files Browse the repository at this point in the history
marcosholgado authored and github-actions[bot] committed Apr 7, 2023
1 parent ca62a15 commit 2a7d08c
Showing 2 changed files with 5 additions and 108 deletions.
61 changes: 2 additions & 59 deletions build/android/contentScope.js
Original file line number Diff line number Diff line change
@@ -610,17 +610,6 @@
}
}

async function update$1 (args) {
if (!shouldRun()) {
return
}
if (initArgs === null) {
updates.push(args);
return
}
updateFeaturesInner(args);
}

function alwaysInitExtensionFeatures (args, featureName) {
return args.platform.name === 'extension' && alwaysInitFeatures.has(featureName)
}
@@ -639,15 +628,6 @@
* @category Content Scope Scripts Integrations
*/

const allowedMessages = [
'getClickToLoadState',
'getYouTubeVideoDetails',
'openShareFeedbackPage',
'setYoutubePreviewsEnabled',
'unblockClickToLoadContent',
'updateYouTubeCTLAddedFlag'
];

function initCode () {
// @ts-expect-error https://app.asana.com/0/1201614831475344/1203979574128023/f
const processedConfig = processConfig($CONTENT_SCOPE$, $USER_UNPROTECTED_DOMAINS$, $USER_PREFERENCES$);
@@ -659,47 +639,10 @@
platform: processedConfig.platform
});

const messageSecret = processedConfig.messageSecret;
// Receives messages from the platform
const messageCallback = processedConfig.messageCallback;
// Sends messages to the platform
const messageInterface = processedConfig.messageInterface;

const wrappedUpdate = ((providedSecret, ...args) => {
if (providedSecret === messageSecret) {
update$1(...args);
}
}).bind();

Object.defineProperty(window, messageCallback, {
value: wrappedUpdate
});

// @ts-ignore
const sendMessageToAndroid = window[messageInterface].process.bind(window[messageInterface]);
delete window[messageInterface];

init$1(processedConfig);

window.addEventListener('sendMessageProxy' + messageSecret, event => {
event.stopImmediatePropagation();

if (!(event instanceof CustomEvent) || !event?.detail) {
return console.warn('no details in sendMessage proxy', event)
}

const messageType = event.detail?.messageType;
if (!allowedMessages.includes(messageType)) {
return console.warn('Ignoring invalid sendMessage messageType', messageType)
}

const message = {
type: messageType,
options: event.detail?.options
};
const stringifiedArgs = JSON.stringify(message);
sendMessageToAndroid(stringifiedArgs, messageSecret);
});
// Not supported:
// update(message)
}

initCode();
52 changes: 3 additions & 49 deletions inject/android.js
Original file line number Diff line number Diff line change
@@ -2,18 +2,9 @@
* @module Android integration
* @category Content Scope Scripts Integrations
*/
import { load, init, update } from '../src/content-scope-features.js'
import { load, init } from '../src/content-scope-features.js'
import { processConfig, isGloballyDisabled } from './../src/utils'

const allowedMessages = [
'getClickToLoadState',
'getYouTubeVideoDetails',
'openShareFeedbackPage',
'setYoutubePreviewsEnabled',
'unblockClickToLoadContent',
'updateYouTubeCTLAddedFlag'
]

function initCode () {
// @ts-expect-error https://app.asana.com/0/1201614831475344/1203979574128023/f
const processedConfig = processConfig($CONTENT_SCOPE$, $USER_UNPROTECTED_DOMAINS$, $USER_PREFERENCES$)
@@ -25,47 +16,10 @@ function initCode () {
platform: processedConfig.platform
})

const messageSecret = processedConfig.messageSecret
// Receives messages from the platform
const messageCallback = processedConfig.messageCallback
// Sends messages to the platform
const messageInterface = processedConfig.messageInterface

const wrappedUpdate = ((providedSecret, ...args) => {
if (providedSecret === messageSecret) {
update(...args)
}
}).bind()

Object.defineProperty(window, messageCallback, {
value: wrappedUpdate
})

// @ts-ignore
const sendMessageToAndroid = window[messageInterface].process.bind(window[messageInterface])
delete window[messageInterface]

init(processedConfig)

window.addEventListener('sendMessageProxy' + messageSecret, event => {
event.stopImmediatePropagation()

if (!(event instanceof CustomEvent) || !event?.detail) {
return console.warn('no details in sendMessage proxy', event)
}

const messageType = event.detail?.messageType
if (!allowedMessages.includes(messageType)) {
return console.warn('Ignoring invalid sendMessage messageType', messageType)
}

const message = {
type: messageType,
options: event.detail?.options
}
const stringifiedArgs = JSON.stringify(message)
sendMessageToAndroid(stringifiedArgs, messageSecret)
})
// Not supported:
// update(message)
}

initCode()

0 comments on commit 2a7d08c

Please sign in to comment.