Line Store Easy Sticker Downloader

This script allows users to easily download stickers from the Line Store website. By left-clicking on any sticker, the preview image will open in a new tab, making it simple to view or download the sticker using the right-click menu.

  1. // ==UserScript==
  2. // @name:zh-tw Line Store 貼圖輕鬆下載器
  3. // @name Line Store Easy Sticker Downloader
  4. // @namespace com.sherryyue.linestickerstoredownloader
  5. // @version 0.5
  6. // @description:zh-tw 此腳本讓用戶能輕鬆下載 Line 貼圖商店網站上的貼圖。左鍵點擊任何貼圖時,預覽圖將在新分頁中開啟,方便瀏覽或右鍵下載貼圖。
  7. // @description This script allows users to easily download stickers from the Line Store website. By left-clicking on any sticker, the preview image will open in a new tab, making it simple to view or download the sticker using the right-click menu.
  8. // @author SherryYue
  9. // @copyright SherryYue
  10. // @license MIT
  11. // @match https://store.line.me/*
  12. // @supportURL sherryyue.c@protonmail.com
  13. // @icon https://sherryyuechiu.github.io/card/images/logo/maskable_icon_x96.png
  14. // @require https://code.jquery.com/jquery-3.6.0.js
  15. // @require https://code.jquery.com/ui/1.13.1/jquery-ui.js
  16. // @supportURL "https://github.com/sherryyuechiu/GreasyMonkeyScripts/issues"
  17. // @homepage "https://github.com/sherryyuechiu/GreasyMonkeyScripts"
  18. // @grant GM_addStyle
  19. // ==/UserScript==
  20.  
  21. (function () {
  22. let downloadImage = (url) => {
  23. var a = document.createElement('a');
  24. a.href = url;
  25. a.download = url;
  26. document.body.appendChild(a);
  27. a.click();
  28. document.body.removeChild(a);
  29. }
  30.  
  31. let main = () => {
  32. $('.FnStickerPreviewItem').on("click", function () {
  33. let data = JSON.parse($(this).attr('data-preview'));
  34. let clearImageUrl = data.fallbackStaticUrl;
  35. downloadImage(clearImageUrl);
  36. console.warn('data', data)
  37. });
  38. }
  39.  
  40. function observerFallBack(mutations, obs) {
  41. if (!document.querySelector(".FnStickerPreviewItem")) return;
  42. setTimeout(main, 250);
  43. observer.disconnect();
  44. }
  45.  
  46. let observer = new MutationObserver(observerFallBack);
  47. observer.observe(document.querySelector("body"), {
  48. childList: true,
  49. subtree: true
  50. });
  51. setTimeout(observerFallBack, 250);
  52.  
  53. document.getElementsByTagName('head')[0].append(
  54. '<link '
  55. + 'href="//code.jquery.com/ui/1.13.1/themes/base/jquery-ui.css" '
  56. + ' type="text/css">'
  57. );
  58. })();
  59.