LINE Append String

Automatic generation of append string for BetterDiscord plugin

  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. // @include https://store.line.me/emojishop/product/*
  7. // @version 0.6.2
  8. // @grant none
  9. // @run-at document-end
  10. // ==/UserScript==
  11.  
  12. (function() {
  13. 'use strict'
  14.  
  15. const title = document.querySelector('.mdCMN38Item01Ttl').innerHTML
  16. const firstItem = document.querySelector('.mdCMN09Image').style['background-image']
  17. const isEmojisPack = firstItem.includes('sticonshop')
  18.  
  19. let id
  20. if (isEmojisPack) {
  21. id = firstItem.match(/sticon\/([a-z0-9]+)/)[1]
  22. } else {
  23. id = firstItem.match(/sticker\/(\d+)/)[1]
  24. }
  25.  
  26. const length = document.querySelectorAll('.mdCMN09Li').length.toString()
  27. let animated
  28. let appendString
  29. if (isEmojisPack) {
  30. appendString = 'magane.appendEmojisPack(\'' + title + '\', \'' + id + '\', ' + length + ')'
  31. } else {
  32. animated = Boolean(document.querySelector('.MdIcoPlay_b') || document.querySelector('.MdIcoAni_b'))
  33. appendString = 'magane.appendPack(\'' + title + '\', ' + id + ', ' + length + ', ' + (animated ? 1 : 0) + ')'
  34. }
  35.  
  36. const href = window.location.pathname.split('/')
  37. const locale = href[href.length - 1]
  38.  
  39. const strings = {
  40. 'title' : 'Title',
  41. 'stickers_count': 'Stickers count',
  42. 'emojis_count': 'Emojis count',
  43. 'id': 'ID',
  44. 'first_id': 'First ID',
  45. 'animated': 'Animated',
  46. 'append': 'Console command'
  47. }
  48.  
  49. const inlineCSS = `background: #2e3136;
  50. padding: 1em;
  51. -webkit-border-radius: 3px;
  52. border-radius: 3px;
  53. font-family: monospace;
  54. line-height: 16px;
  55. color: rgba(255,255,255,.7);
  56. margin: 10px 0;`
  57.  
  58. const idString = isEmojisPack ? strings.id : strings.first_id
  59.  
  60. let infoString = `${strings.title}: ${title}\n${idString}: ${id}`
  61. if (isEmojisPack) {
  62. infoString += `\n${strings.emojis_count}: ${length}`
  63. } else {
  64. infoString += `\n${strings.stickers_count}: ${length}\n${strings.animated}: ${String(animated)}`
  65. }
  66. infoString += `\n\n${strings.append}:\n${appendString}`
  67.  
  68. console.log(infoString)
  69. document.querySelector('.mdCMN38Item01Txt').innerHTML += `<p style='${inlineCSS.replace(/\n/g, ' ')}'>${infoString.replace(/\n/g, '<br>')}</p>`
  70. })();