Download stickers from LINE store pages using GM_download
当前为
// ==UserScript==
// @name Line Sticker Downloader
// @namespace http://tampermonkey.net/
// @version 0.1
// @description Download stickers from LINE store pages using GM_download
// @author cheerchen
// @match https://store.line.me/stickershop/product/*
// @grant GM_download
// @license MIT
// ==/UserScript==
(function() {
'use strict';
function extractAndDownload() {
const stickerList = document.querySelectorAll('.FnStickerList li');
stickerList.forEach((li) => {
const dataPreview = li.getAttribute('data-preview');
if (dataPreview) {
const preview = JSON.parse(dataPreview);
const url = preview.animationUrl ? preview.animationUrl : preview.staticUrl;
const filename = preview.id + (preview.animationUrl ? '.png' : '.png');
// Using GM_download to initiate the download
GM_download({
url: url,
name: filename,
saveAs: false, // Change to true if you want to prompt for save location
onerror: function(error) {
console.error('Download failed:', error);
},
onload: function() {
console.log('Download completed:', filename);
}
});
}
});
}
// Add a button to trigger download
const downloadBtn = document.createElement('button');
downloadBtn.textContent = 'Download Stickers';
downloadBtn.style.position = 'fixed';
downloadBtn.style.top = '10px';
downloadBtn.style.right = '10px';
downloadBtn.style.zIndex = '1000';
downloadBtn.style.padding = '10px 20px';
downloadBtn.style.background = '#4CAF50';
downloadBtn.style.color = 'white';
downloadBtn.style.border = 'none';
downloadBtn.style.borderRadius = '5px';
downloadBtn.style.cursor = 'pointer';
downloadBtn.addEventListener('click', extractAndDownload);
document.body.appendChild(downloadBtn);
})();