Skip to content

Commit bced8cd

Browse files
committed
[amazon subs] switch to GM.xmlHttpRequest
1 parent d742825 commit bced8cd

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

Amazon_Video_-_subtitle_downloader.user.js

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,17 @@
22
// @name Amazon Video - subtitle downloader
33
// @description Allows you to download subtitles from Amazon Video
44
// @license MIT
5-
// @version 1.7.1
5+
// @version 1.7.2
66
// @namespace tithen-firion.github.io
77
// @include /^https:\/\/www\.amazon\.com\/(gp\/(video|product)|(.*?\/)?dp)\/.+/
88
// @include /^https:\/\/www\.amazon\.de\/(gp\/(video|product)|(.*?\/)?dp)\/.+/
99
// @include /^https:\/\/www\.amazon\.co\.uk\/(gp\/(video|product)|(.*?\/)?dp)\/.+/
1010
// @include /^https:\/\/www\.amazon\.co\.jp\/(gp\/(video|product)|(.*?\/)?dp)\/.+/
1111
// @include /^https:\/\/www\.primevideo\.com\/(gp\/video|(region\/.*?\/)?detail)/.+/
1212
// @grant unsafeWindow
13+
// @grant GM.xmlHttpRequest
14+
// @grant GM_xmlhttpRequest
15+
// @require https://greasemonkey.github.io/gm4-polyfill/gm4-polyfill.js
1316
// @require https://cdn.jsdelivr.net/gh/Tithen-Firion/UserScripts@7bd6406c0d264d60428cfea16248ecfb4753e5e3/libraries/xhrHijacker.js?version=1.0
1417
// @require https://cdn.jsdelivr.net/gh/Stuk/jszip@579beb1d45c8d586d8be4411d5b2e48dea018c06/dist/jszip.min.js?version=3.1.5
1518
// @require https://cdn.jsdelivr.net/gh/eligrey/FileSaver.js@283f438c31776b622670be002caf1986c40ce90c/dist/FileSaver.min.js?version=2018-12-29
@@ -101,28 +104,31 @@ function xmlToSrt(xmlString, lang) {
101104

102105
// download subs and save them
103106
function downloadSubs(url, title, downloadVars, lang) {
104-
var req = new XMLHttpRequest();
105-
req.open('get', url);
106-
req.onload = function() {
107+
GM.xmlHttpRequest({
108+
url: url,
109+
method: 'get',
110+
onload: function(resp) {
111+
107112
progressBar.increment();
108-
var srt = xmlToSrt(req.response, lang);
113+
var srt = xmlToSrt(resp.responseText, lang);
109114
if(downloadVars) {
110115
downloadVars.zip.file(title, srt);
111116
--downloadVars.subCounter;
112117
if((downloadVars.subCounter|downloadVars.infoCounter) === 0)
113118
downloadVars.zip.generateAsync({type:"blob"})
114119
.then(function(content) {
115120
saveAs(content, 'subs.zip');
116-
progressBar.destroy();
121+
progressBar.destroy();
117122
});
118123
}
119124
else {
120125
var blob = new Blob([srt], {type: 'text/plain;charset=utf-8'});
121126
saveAs(blob, title, true);
122127
progressBar.destroy();
123128
}
124-
};
125-
req.send(null);
129+
130+
}
131+
});
126132
}
127133

128134
// download episodes/movie info and start downloading subs

0 commit comments

Comments
 (0)