LINE Append String

Automatic generation of append string for BetterDiscord plugin

目前为 2018-10-19 提交的版本。查看 最新版本

  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.4.0
  7. // @grant none
  8. // @run-at document-end
  9. // ==/UserScript==
  10.  
  11. var title = document.querySelector('.mdCMN08Ttl').innerHTML;
  12. var firstStickerID = document.querySelector('.mdCMN09Image').style['background-image'].match(/sticker\/(\d+)/)[1];
  13. var length = document.querySelectorAll('.mdCMN09Li').length.toString();
  14. var animated = Boolean(document.querySelector('.MdIcoPlay_b'));
  15. var append_string = 'maganeAppendPack(`' + title + '`, ' + firstStickerID + ', ' + length + ', ' + (animated ? 1 : 0) + ')';
  16.  
  17. var href = window.location.pathname.split('/');
  18. var locale = href[href.length - 1]
  19.  
  20. var strings = {
  21. 'title' : 'Title',
  22. 'count': 'Sticker count',
  23. 'first_id': 'First sticker ID',
  24. 'animated': 'Animated',
  25. 'append': 'Console command'
  26. }
  27. if (locale === 'ja') {
  28. strings = {
  29. 'title' : 'タイトル',
  30. 'count': 'スタンプの数',
  31. 'first_id': '最初のスタンプID',
  32. 'append': '追加のコマンド'
  33. }
  34. }
  35.  
  36. var inlineCSS = `background: #2e3136;
  37. padding: 1em;
  38. -webkit-border-radius: 3px;
  39. border-radius: 3px;
  40. font-family: Consolas, "Liberation Mono", Menlo, Courier, monospace;
  41. line-height: 16px;
  42. color: rgba(255,255,255,.7);
  43. margin: 10px 0;`;
  44.  
  45. console.log(`
  46. ${strings['title']}: ${title}
  47. ${strings['first_id']}: ${firstStickerID}
  48. ${strings['count']}: ${length}
  49. ${strings['animated']}: ${String(animated)}
  50. ${strings['append']}:
  51. ${append_string}
  52. `);
  53.  
  54. document.querySelector('.mdCMN08Txt').innerHTML += `
  55. <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. `;