Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 15 additions & 12 deletions xcode/Safari-Extension/Resources/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -414,18 +414,21 @@ function handleMessage(request, sender, sendResponse) {
if (["", "text"].indexOf(xhr.responseType) !== -1) {
x.responseText = xhr.responseText;
}
// need to convert arraybuffer data to postMessage
if (xhr.responseType === "arraybuffer") {
const arr = Array.from(new Uint8Array(xhr.response));
x.response = arr;
}
// need to blob arraybuffer data to postMessage
if (xhr.responseType === "blob") {
const base64data = await readAsDataURL(xhr.response);
x.response = {
data: base64data,
type: xhr.responseType
};
// only process when xhr is complete and data exist
if (xhr.readyState === 4 && xhr.response !== null) {
// need to convert arraybuffer data to postMessage
if (xhr.responseType === "arraybuffer") {
const arr = Array.from(new Uint8Array(xhr.response));
x.response = arr;
}
// need to convert blob data to postMessage
if (xhr.responseType === "blob") {
const base64data = await readAsDataURL(xhr.response);
x.response = {
data: base64data,
type: xhr.responseType
};
}
}
port.postMessage({name: e, event, response: x});
};
Expand Down
31 changes: 17 additions & 14 deletions xcode/Safari-Extension/Resources/content.js
Original file line number Diff line number Diff line change
Expand Up @@ -160,21 +160,24 @@ const apis = {
) {
// process xhr response
const r = msg.response;
if (r.responseType === "arraybuffer") {
// arraybuffer responses had their data converted in background
// convert it back to arraybuffer
try {
const buffer = new Uint8Array(r.response).buffer;
r.response = buffer;
} catch (err) {
console.error("error parsing xhr arraybuffer", err);
// only process when xhr is complete and data exist
if (r.readyState === 4 && r.response !== null) {
if (r.responseType === "arraybuffer") {
// arraybuffer responses had their data converted in background
// convert it back to arraybuffer
try {
const buffer = new Uint8Array(r.response).buffer;
r.response = buffer;
} catch (err) {
console.error("error parsing xhr arraybuffer", err);
}
} else if (r.responseType === "blob" && r.response.data) {
// blob responses had their data converted in background
// convert it back to blob
const resp = await fetch(r.response.data);
const b = await resp.blob();
r.response = b;
}
} else if (r.responseType === "blob" && r.response.data) {
// blob responses had their data converted in background
// convert it back to blob
const resp = await fetch(r.response.data);
const b = await resp.blob();
r.response = b;
}
// call userscript method
details[msg.name](msg.response);
Expand Down
2 changes: 1 addition & 1 deletion xcode/Safari-Extension/Resources/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"default_locale": "en",
"name": "__MSG_extension_name__",
"description": "__MSG_extension_description__",
"version": "4.4.4",
"version": "4.4.5",
"icons": {
"48": "images/icon-48.png",
"96": "images/icon-96.png",
Expand Down
8 changes: 4 additions & 4 deletions xcode/xcconfig/Userscripts-Release.xcconfig
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#include "Userscripts-Base.xcconfig"

INFOPLIST_KEY_NSHumanReadableCopyright = Copyright © 2018–2023 Justin Wasack. All rights reserved.
IOS_APP_BUILD = 53
IOS_APP_VERSION = 1.4.4
MAC_APP_BUILD = 80
MAC_APP_VERSION = 4.4.4
IOS_APP_BUILD = 56
IOS_APP_VERSION = 1.4.5
MAC_APP_BUILD = 82
MAC_APP_VERSION = 4.4.5

// Developer Team ID
DEVELOPMENT_TEAM = J74Q8V8V8N
Expand Down