2
2
* @module Android integration
3
3
* @category Content Scope Scripts Integrations
4
4
*/
5
- import { load, init, update } from '../src/content-scope-features.js'
5
+ import { load, init } from '../src/content-scope-features.js'
6
6
import { processConfig, isGloballyDisabled } from './../src/utils'
7
7
8
- const allowedMessages = [
9
- 'getClickToLoadState',
10
- 'getYouTubeVideoDetails',
11
- 'openShareFeedbackPage',
12
- 'setYoutubePreviewsEnabled',
13
- 'unblockClickToLoadContent',
14
- 'updateYouTubeCTLAddedFlag'
15
- ]
16
-
17
8
function initCode () {
18
9
// @ts-expect-error https://app.asana.com/0/1201614831475344/1203979574128023/f
19
10
const processedConfig = processConfig($CONTENT_SCOPE$, $USER_UNPROTECTED_DOMAINS$, $USER_PREFERENCES$)
@@ -25,47 +16,10 @@ function initCode () {
25
16
platform: processedConfig.platform
26
17
})
27
18
28
- const messageSecret = processedConfig.messageSecret
29
- // Receives messages from the platform
30
- const messageCallback = processedConfig.messageCallback
31
- // Sends messages to the platform
32
- const messageInterface = processedConfig.messageInterface
33
-
34
- const wrappedUpdate = ((providedSecret, ...args) => {
35
- if (providedSecret === messageSecret) {
36
- update(...args)
37
- }
38
- }).bind()
39
-
40
- Object.defineProperty(window, messageCallback, {
41
- value: wrappedUpdate
42
- })
43
-
44
- // @ts-ignore
45
- const sendMessageToAndroid = window[messageInterface].process.bind(window[messageInterface])
46
- delete window[messageInterface]
47
-
48
19
init(processedConfig)
49
20
50
- window.addEventListener('sendMessageProxy' + messageSecret, event => {
51
- event.stopImmediatePropagation()
52
-
53
- if (!(event instanceof CustomEvent) || !event?.detail) {
54
- return console.warn('no details in sendMessage proxy', event)
55
- }
56
-
57
- const messageType = event.detail?.messageType
58
- if (!allowedMessages.includes(messageType)) {
59
- return console.warn('Ignoring invalid sendMessage messageType', messageType)
60
- }
61
-
62
- const message = {
63
- type: messageType,
64
- options: event.detail?.options
65
- }
66
- const stringifiedArgs = JSON.stringify(message)
67
- sendMessageToAndroid(stringifiedArgs, messageSecret)
68
- })
21
+ // Not supported:
22
+ // update(message)
69
23
}
70
24
71
25
initCode()
0 commit comments