Skip to content

Commit

Permalink
Update Download Weibo Images & videos.user.js
Browse files Browse the repository at this point in the history
  • Loading branch information
owendswang authored Jun 2, 2024
1 parent 874ed3b commit 9bdfb03
Showing 1 changed file with 25 additions and 18 deletions.
43 changes: 25 additions & 18 deletions Download Weibo Images & videos.user.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// ==UserScript==
// @name Download Weibo Images & Videos (Only support new version weibo UI)
// @name:zh-CN 下载微博图片和视频(仅支持新版界面)
// @version 1.1.8
// @version 1.1.9
// @description Download images and videos from new version weibo UI webpage.
// @description:zh-CN 从新版微博界面下载图片和视频。
// @author OWENDSWANG
Expand Down Expand Up @@ -31,6 +31,8 @@
// @namespace http://tampermonkey.net/
// @run-at document-end
// @require https://cdnjs.cloudflare.com/ajax/libs/jszip/3.9.1/jszip.min.js
// @downloadURL https://update.greasyfork.org/scripts/430877/Download%20Weibo%20Images%20%20Videos%20%28Only%20support%20new%20version%20weibo%20UI%29.user.js
// @updateURL https://update.greasyfork.org/scripts/430877/Download%20Weibo%20Images%20%20Videos%20%28Only%20support%20new%20version%20weibo%20UI%29.meta.js
// ==/UserScript==

(function() {
Expand Down Expand Up @@ -252,22 +254,6 @@

function httpRequest(url, method = 'GET', data = null) {
return new Promise(function(resolve, reject) {
/*GM_xmlhttpRequest({
method: 'GET',
url,
responseType: 'json',
headers: {
'Referer': 'https://' + location.host,
'Origin': 'https://' + location.host
},
onload: ({ status, response }) => {
// console.log(response);
resolve(response)
},
onabort: function(e) { resolve(null); },
onerror: function(e) { resolve(null); },
ontimeout: function(e) { resolve(null); },
});*/
let oReq = new XMLHttpRequest();
oReq.open(method, url);
oReq.responseType = 'json';
Expand All @@ -287,6 +273,27 @@
});
}

function GM_httpRequest(url, method = 'GET', data = null) {
return new Promise(function(resolve, reject) {
GM_xmlhttpRequest({
method: 'GET',
url,
responseType: 'json',
headers: {
'Referer': 'https://' + location.host,
'Origin': 'https://' + location.host
},
onload: ({ status, response }) => {
// console.log(response);
resolve(response)
},
onabort: function(e) { resolve(null); },
onerror: function(e) { resolve(null); },
ontimeout: function(e) { resolve(null); },
});
});
}

function downloadError(e, url, name, headerFlag, progress, zipMode = false, ariaMode = false) {
// console.log(e, url);
/*GM_notification({
Expand Down Expand Up @@ -889,7 +896,7 @@
// console.log(mid);
if(mid) {
// console.log('https://' + location.host + '/ajax/statuses/show?id=' + mid);
const resJson = await httpRequest('https://weibo.com/ajax/statuses/show?id=' + mid);
const resJson = await GM_httpRequest('https://weibo.com/ajax/statuses/show?id=' + mid);
// console.log(resJson);
let status = resJson;
let retweetPostId, retweetUserName, retweetUserId, retweetPostUid, retweetPostTime, retweetText;
Expand Down

0 comments on commit 9bdfb03

Please sign in to comment.