diff --git a/Bilibili Download Pictures.user.js b/Bilibili Download Pictures.user.js index 0f7e649..87ec1c2 100644 --- a/Bilibili Download Pictures.user.js +++ b/Bilibili Download Pictures.user.js @@ -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);