Skip to content

Commit 29188e5

Browse files
Revert "Add Android messaging integration (#380)"
This reverts commit 2aa9766.
1 parent 74beb72 commit 29188e5

File tree

1 file changed

+3
-49
lines changed

1 file changed

+3
-49
lines changed

inject/android.js

Lines changed: 3 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,9 @@
22
* @module Android integration
33
* @category Content Scope Scripts Integrations
44
*/
5-
import { load, init, update } from '../src/content-scope-features.js'
5+
import { load, init } from '../src/content-scope-features.js'
66
import { processConfig, isGloballyDisabled } from './../src/utils'
77

8-
const allowedMessages = [
9-
'getClickToLoadState',
10-
'getYouTubeVideoDetails',
11-
'openShareFeedbackPage',
12-
'setYoutubePreviewsEnabled',
13-
'unblockClickToLoadContent',
14-
'updateYouTubeCTLAddedFlag'
15-
]
16-
178
function initCode () {
189
// @ts-expect-error https://app.asana.com/0/1201614831475344/1203979574128023/f
1910
const processedConfig = processConfig($CONTENT_SCOPE$, $USER_UNPROTECTED_DOMAINS$, $USER_PREFERENCES$)
@@ -25,47 +16,10 @@ function initCode () {
2516
platform: processedConfig.platform
2617
})
2718

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-
4819
init(processedConfig)
4920

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)
6923
}
7024

7125
initCode()

0 commit comments

Comments
 (0)