Skip to content

Commit eb58929

Browse files
committed
1.17.5
[mv3] Load user script for iframes
1 parent 3eaff3f commit eb58929

File tree

3 files changed

+19
-7
lines changed

3 files changed

+19
-7
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "Surfingkeys",
3-
"version": "1.17.4",
3+
"version": "1.17.5",
44
"description": "Map your keys for web surfing, expand your browser with javascript and keyboard.",
55
"main": "background.js",
66
"directories": {

src/content_scripts/content.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,9 @@ window.getFrameId = function () {
188188
&& window.frameElement.offsetWidth > 16 && window.frameElement.offsetWidth > 16))
189189
) {
190190
_initContent(_initModules());
191+
192+
// Only used to load user script for iframes in MV3
193+
dispatchSKEvent('user', ["runUserScript"]);
191194
}
192195
return window.frameId;
193196
};

src/user_scripts/index.js

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ const functionsToListSuggestions = {};
6868
let inlineQuery;
6969
let hintsFunction;
7070
let onClipboardReadFn;
71+
let userScriptTask = () => {};
7172
initSKFunctionListener("user", {
7273
callUserFunction: (keys, para) => {
7374
if (userDefinedFunctions.hasOwnProperty(keys)) {
@@ -93,6 +94,9 @@ initSKFunctionListener("user", {
9394
}
9495
});
9596
},
97+
runUserScript: () => {
98+
userScriptTask();
99+
},
96100
onClipboardRead: (resp) => {
97101
onClipboardReadFn(resp);
98102
},
@@ -227,11 +231,16 @@ const api = {
227231
export default (extensionRootUrl, uf) => {
228232
EXTENSION_ROOT_URL = extensionRootUrl;
229233
if (isInUIFrame()) return;
230-
var settings = {}, error = "";
231-
try {
232-
uf(api, settings);
233-
} catch(e) {
234-
error = e.toString();
234+
userScriptTask = () => {
235+
var settings = {}, error = "";
236+
try {
237+
uf(api, settings);
238+
} catch(e) {
239+
error = e.toString();
240+
}
241+
applyUserSettings({settings, error});
242+
};
243+
if (window === top) {
244+
userScriptTask();
235245
}
236-
applyUserSettings({settings, error});
237246
};

0 commit comments

Comments
 (0)