Skip to content

Commit 2cebecf

Browse files
committed
Fixed up cors issues by using GM_xmlhttpRequest
1 parent 8310741 commit 2cebecf

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

wasm/violentmonkey.js

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
// @grant none
66
// @version 1.0
77
// @author -
8+
// @grant GM_xmlhttpRequest
89
// @inject-into content
910
// @require http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js
1011
// @require https://gist.github.com/raw/2625891/waitForKeyElements.js
@@ -591,13 +592,14 @@ function dumpToHcl() {
591592
nav.append(hclOutput);
592593

593594
// Download the WASM file
594-
fetch("https://github.com/mcasperson/OctopusTerraformExport/raw/main/wasm/convert_project.wasm")
595-
.then(function(response) {
596-
return response.arrayBuffer();
597-
})
598-
.then(function(buffer) {
595+
GM_xmlhttpRequest({
596+
method: "GET",
597+
url: "https://github.com/mcasperson/OctopusTerraformExport/raw/main/wasm/convert_project.wasm",
598+
responseType: "arraybuffer",
599+
onload: function(e) {
600+
console.log(e)
599601
const go = new Go();
600-
WebAssembly.instantiate(buffer, go.importObject)
602+
WebAssembly.instantiate(e.response, go.importObject)
601603
.then((result) => {
602604
go.run(result.instance)
603605

@@ -641,7 +643,8 @@ function dumpToHcl() {
641643
.catch(function(err) {
642644
console.log(err);
643645
})
644-
});
646+
}
647+
});
645648
}
646649
} catch (err) {
647650
console.log(err);

0 commit comments

Comments
 (0)