MCPcopy
hub / github.com/NeverDecaf/chromium-web-store / promptInstall

Function promptInstall

src/scripts/util.js:101–145  ·  view source on GitHub ↗
(
    crx_url,
    is_webstore,
    browser = WEBSTORE.chrome,
    custom_msg_handler = undefined,
)

Source from the content-addressed store, hash-verified

99}
100
101function promptInstall(
102 crx_url,
103 is_webstore,
104 browser = WEBSTORE.chrome,
105 custom_msg_handler = undefined,
106) {
107 chrome.storage.sync.get(DEFAULT_MANAGEMENT_OPTIONS, function (settings) {
108 var msgHandler = custom_msg_handler || chrome.runtime.sendMessage;
109 if (is_webstore && !settings.manually_install) {
110 switch (browser) {
111 case WEBSTORE.edge:
112 // normal methods fail because microsoft's official web store redirects you from HTTPS to an insecure HTTP url.
113 // instead use chrome.tabs to open the url in a new tab.
114 msgHandler({
115 newTabUrl: crx_url,
116 });
117 break;
118 case WEBSTORE.opera:
119 // Opera extensions will always error with CRX_HEADER_INVALID, they must be "load unpacked"
120 msgHandler({
121 manualInstallDownloadUrl: crx_url,
122 });
123 break;
124 default:
125 // copy the edge method instead of window.open(,_blank) so this works in the service worker (mv3)
126 msgHandler({
127 newTabUrl: crx_url,
128 });
129 break;
130 }
131 return;
132 }
133 if (settings.manually_install) {
134 msgHandler({
135 manualInstallDownloadUrl: crx_url,
136 });
137 return;
138 } else {
139 msgHandler({
140 nonWebstoreDownloadUrl: crx_url,
141 });
142 return;
143 }
144 });
145}
146
147function checkForUpdates(
148 update_callback = null,

Callers 7

load_optionsFunction · 0.70
handleContextClickFunction · 0.70
background.jsFile · 0.70
popup.jsFile · 0.70
createButtonFunction · 0.70
modifyNewCWSButtonFunction · 0.70
inject.jsFile · 0.70

Calls 1

msgHandlerFunction · 0.70

Tested by

no test coverage detected