Skip to content

Commit

Permalink
Update Bilibili Download Pictures.user.js
Browse files Browse the repository at this point in the history
owendswang authored Apr 5, 2023
1 parent b90e80b commit 5e3c984
Showing 1 changed file with 16 additions and 14 deletions.
30 changes: 16 additions & 14 deletions Bilibili Download Pictures.user.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// ==UserScript==
// @name Bilibili Download Pictures
// @name:zh-CN 下载Bilibili动态页面图片
// @version 0.7.5
// @version 0.7.6
// @description Download pictures from bilibili timeline
// @description:zh-CN 下载“Bilibili动态”时间线页面的图片
// @author OWENDSWANG
@@ -44,7 +44,7 @@
const list = content.querySelectorAll('div.bili-album__preview__picture__img');
// console.log(list);
for (const item of list) {
let imgUrl = item.style.backgroundImage.split(/"|@/)[1];
let imgUrl = item.style.backgroundImage.split(/"|@/)[1] || item.querySelector('img').src.split('@')[0];
if (imgUrl.startsWith('//')) {
imgUrl = 'https:' + imgUrl;
}
@@ -54,19 +54,21 @@
GM_download(imgUrl, imgName);
}
const topAlbum = document.body.querySelector('div.opus-module-top__album');
const topAlbumIndicatorList = topAlbum.querySelectorAll('div.horizontal-scroll-album__indicator > div > img');
const topAlbumList = topAlbum.querySelectorAll('div.horizontal-scroll-album__pic__img > img');
let topList = topAlbumList;
if (topAlbumIndicatorList.length > 0) topList = topAlbumIndicatorList;
for (const item of topList) {
let imgUrl = item.src.split(/@/)[0];
if (imgUrl.startsWith('//')) {
imgUrl = 'https:' + imgUrl;
if (topAlbum) {
const topAlbumIndicatorList = topAlbum.querySelectorAll('div.horizontal-scroll-album__indicator > div > img');
const topAlbumList = topAlbum.querySelectorAll('div.horizontal-scroll-album__pic__img > img');
let topList = topAlbumList;
if (topAlbumIndicatorList.length > 0) topList = topAlbumIndicatorList;
for (const item of topList) {
let imgUrl = item.src.split(/@/)[0];
if (imgUrl.startsWith('//')) {
imgUrl = 'https:' + imgUrl;
}
const imgName = imgUrl.split('/')[imgUrl.split('/').length - 1];
// console.log(imgUrl);
// console.log(imgName);
GM_download(imgUrl, imgName);
}
const imgName = imgUrl.split('/')[imgUrl.split('/').length - 1];
// console.log(imgUrl);
// console.log(imgName);
GM_download(imgUrl, imgName);
}
});
buttonBar.appendChild(downloadButton);

0 comments on commit 5e3c984

Please sign in to comment.