Last active
November 21, 2019 17:21
-
-
Save Modder4869/aa2f31c58c26bc1924e0fe2b08d89e89 to your computer and use it in GitHub Desktop.
Line stickers save as , badly written , you can see my random comments!, but it works demo:https://gfycat.com/MinorInconsequentialBetafish
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // ==UserScript== | |
| // @name Save stickers zip Userscript | |
| // @namespace http://tampermonkey.net/ | |
| // @version 0.1 | |
| // @description add sticker link next to gift or see other items button | |
| // @author Modder4869 | |
| // @match https://store.line.me/stickershop/product/* | |
| // @grant none | |
| // ==/UserScript== | |
| (function() { | |
| 'use strict'; | |
| //declare product id | |
| //declare product id | |
| var productID; | |
| var stickerZipName; | |
| // get product id from current link | |
| productID=window.location.href.split('/product')[1].split('/')[1] | |
| // declare download link | |
| // var downloadLink = `https://stickershop.line-scdn.net/stickershop/v1/product/${productID}/android/stickers.zip` | |
| var downloadLink = `https://stickershop.line-scdn.net/stickershop/v1/product/${productID}/iphone/stickers@2x.zip` | |
| var copyButtonHtml=`<a href=${downloadLink}>Right click then save as to download sticker</a>`; | |
| //log downloadLink | |
| console.log(downloadLink); | |
| //find send as gift or see other items button | |
| var sendAsGift = document.querySelector('.MdBtn01P02'); | |
| var seeOthersItems = document.querySelector('.mdMN05Btn'); | |
| //clone save as gif button or other items if it doesn't exist | |
| if(seeOthersItems){ | |
| var cloneCopyButton = seeOthersItems.cloneNode(true) | |
| document.querySelector('.mdMN05Btn').appendChild(cloneCopyButton) | |
| } | |
| else if (sendAsGift){ | |
| cloneCopyButton = sendAsGift.cloneNode(true) | |
| document.querySelector('.mdCMN38Item01').appendChild(cloneCopyButton) | |
| } | |
| cloneCopyButton.outerHTML=copyButtonHtml | |
| cloneCopyButton.innerText = "CopyLink" | |
| console.log(cloneCopyButton) | |
| // function getStickerZipURL(){ | |
| // //copy sticker downloadLink to clipboard | |
| // copyToClipboard(downloadLink); | |
| // } | |
| //find better way to add button | |
| // ...... | |
| //copy to clipboard function | |
| // function copyToClipboard (str){ | |
| // let el = document.createElement('textarea'); | |
| // el.value = str; | |
| // document.body.appendChild(el); | |
| // el.select(); | |
| // document.execCommand('copy'); | |
| // document.body.removeChild(el); | |
| // }; | |
| function downloadFileLink(){ | |
| // var fileName = 'downloadLink.zip'; | |
| var link = document.createElement("a"); | |
| //source https://stackoverflow.com/questions/27115748/download-attribute-not-working-in-firefox | |
| if (link.download !== undefined) { // feature detection | |
| // Browsers that support HTML5 download attribute | |
| link.setAttribute("href", downloadLink); | |
| // link.setAttribute("download", fileName); | |
| // link.setAttribute("target", "_blank"); | |
| // link.download=fileName | |
| document.body.appendChild(link); | |
| link.click(); | |
| document.body.removeChild(link); | |
| } else { | |
| alert('Stickers download only works in Chrome, Firefox, and Opera.'); | |
| } | |
| } | |
| })(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment