|
2 | 2 | // @name Amazon Video - subtitle downloader
|
3 | 3 | // @description Allows you to download subtitles from Amazon Video
|
4 | 4 | // @license MIT
|
5 |
| -// @version 1.7.1 |
| 5 | +// @version 1.7.2 |
6 | 6 | // @namespace tithen-firion.github.io
|
7 | 7 | // @include /^https:\/\/www\.amazon\.com\/(gp\/(video|product)|(.*?\/)?dp)\/.+/
|
8 | 8 | // @include /^https:\/\/www\.amazon\.de\/(gp\/(video|product)|(.*?\/)?dp)\/.+/
|
9 | 9 | // @include /^https:\/\/www\.amazon\.co\.uk\/(gp\/(video|product)|(.*?\/)?dp)\/.+/
|
10 | 10 | // @include /^https:\/\/www\.amazon\.co\.jp\/(gp\/(video|product)|(.*?\/)?dp)\/.+/
|
11 | 11 | // @include /^https:\/\/www\.primevideo\.com\/(gp\/video|(region\/.*?\/)?detail)/.+/
|
12 | 12 | // @grant unsafeWindow
|
| 13 | +// @grant GM.xmlHttpRequest |
| 14 | +// @grant GM_xmlhttpRequest |
| 15 | +// @require https://greasemonkey.github.io/gm4-polyfill/gm4-polyfill.js |
13 | 16 | // @require https://cdn.jsdelivr.net/gh/Tithen-Firion/UserScripts@7bd6406c0d264d60428cfea16248ecfb4753e5e3/libraries/xhrHijacker.js?version=1.0
|
14 | 17 | // @require https://cdn.jsdelivr.net/gh/Stuk/jszip@579beb1d45c8d586d8be4411d5b2e48dea018c06/dist/jszip.min.js?version=3.1.5
|
15 | 18 | // @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) {
|
101 | 104 |
|
102 | 105 | // download subs and save them
|
103 | 106 | 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 | + |
107 | 112 | progressBar.increment();
|
108 |
| - var srt = xmlToSrt(req.response, lang); |
| 113 | + var srt = xmlToSrt(resp.responseText, lang); |
109 | 114 | if(downloadVars) {
|
110 | 115 | downloadVars.zip.file(title, srt);
|
111 | 116 | --downloadVars.subCounter;
|
112 | 117 | if((downloadVars.subCounter|downloadVars.infoCounter) === 0)
|
113 | 118 | downloadVars.zip.generateAsync({type:"blob"})
|
114 | 119 | .then(function(content) {
|
115 | 120 | saveAs(content, 'subs.zip');
|
116 |
| - progressBar.destroy(); |
| 121 | + progressBar.destroy(); |
117 | 122 | });
|
118 | 123 | }
|
119 | 124 | else {
|
120 | 125 | var blob = new Blob([srt], {type: 'text/plain;charset=utf-8'});
|
121 | 126 | saveAs(blob, title, true);
|
122 | 127 | progressBar.destroy();
|
123 | 128 | }
|
124 |
| - }; |
125 |
| - req.send(null); |
| 129 | + |
| 130 | + } |
| 131 | + }); |
126 | 132 | }
|
127 | 133 |
|
128 | 134 | // download episodes/movie info and start downloading subs
|
|
0 commit comments