LINE Append String

Automatic generation of append string for BetterDiscord plugin

目前为 2020-11-06 提交的版本。查看 最新版本

  1. // ==UserScript==
  2. // @name LINE Append String
  3. // @namespace lineappendstring
  4. // @description Automatic generation of append string for BetterDiscord plugin
  5. // @include https://store.line.me/stickershop/product/*
  6. // @version 0.5.1
  7. // @grant none
  8. // @run-at document-end
  9. // ==/UserScript==
  10.  
  11. (function() {
  12. 'use strict';
  13.  
  14. var title = document.querySelector('.mdCMN38Item01Ttl').innerHTML;
  15. var firstStickerID = document.querySelector('.mdCMN09Image').style['background-image'].match(/sticker\/(\d+)/)[1];
  16. var length = document.querySelectorAll('.mdCMN09Li').length.toString();
  17. var animated = Boolean(document.querySelector('.MdIcoPlay_b'));
  18. var append_string = 'magane.appendPack(`' + title + '`, ' + firstStickerID + ', ' + length + ', ' + (animated ? 1 : 0) + ')';
  19.  
  20. var href = window.location.pathname.split('/');
  21. var locale = href[href.length - 1]
  22.  
  23. var strings = {
  24. 'title' : 'Title',
  25. 'count': 'Sticker count',
  26. 'first_id': 'First sticker ID',
  27. 'animated': 'Animated',
  28. 'append': 'Console command'
  29. }
  30. if (locale === 'ja') {
  31. strings = {
  32. 'title' : 'タイトル',
  33. 'count': 'スタンプの数',
  34. 'first_id': '最初のスタンプID',
  35. 'append': '追加のコマンド'
  36. }
  37. }
  38.  
  39. var inlineCSS = `background: #2e3136;
  40. padding: 1em;
  41. -webkit-border-radius: 3px;
  42. border-radius: 3px;
  43. font-family: monospace;
  44. line-height: 16px;
  45. color: rgba(255,255,255,.7);
  46. margin: 10px 0;`;
  47.  
  48. console.log(`${strings['title']}: ${title}
  49. ${strings['first_id']}: ${firstStickerID}
  50. ${strings['count']}: ${length}
  51. ${strings['animated']}: ${String(animated)}
  52. ${strings['append']}:
  53. ${append_string}`);
  54.  
  55. document.querySelector('.mdCMN38Item01Txt').innerHTML += `<p style='${inlineCSS}'>
  56. ${strings['title']}: ${title}<br>
  57. ${strings['first_id']}: ${firstStickerID}<br>
  58. ${strings['count']}: ${length}<br>
  59. ${strings['animated']}: ${String(animated)}<br>
  60. ${strings['append']}: <br>
  61. ${append_string}
  62. </p>`;
  63. })();