LINE Append String

Automatic generation of append string for BetterDiscord plugin

Από την 23/04/2019. Δείτε την τελευταία έκδοση.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey, το Greasemonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Userscripts για να εγκαταστήσετε αυτόν τον κώδικα.

You will need to install an extension such as Tampermonkey to install this script.

Θα χρειαστεί να εγκαταστήσετε μια επέκταση διαχείρισης κώδικα χρήστη για να εγκαταστήσετε αυτόν τον κώδικα.

(Έχω ήδη έναν διαχειριστή κώδικα χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(Έχω ήδη έναν διαχειριστή στυλ χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

// ==UserScript==
// @name        LINE Append String
// @namespace   lineappendstring
// @description Automatic generation of append string for BetterDiscord plugin
// @include     https://store.line.me/stickershop/product/*
// @version     0.4.0
// @grant       none
// ==/UserScript==

function getStrings () {
  let href = window.location.pathname.split('/')
  let locale = href[href.length - 1]
  if (locale === 'ja') {
    return {
      'title': 'タイトル',
      'count': 'スタンプの数',
      'firstID': '最初のスタンプID',
      'append': '追加のコマンド'
    }
  } else {
  	return {
      'title': 'Title',
      'count': 'Sticker count',
      'firstID': 'First sticker ID',
      'append': 'Console command'
    }
  }
}


let title = document.querySelector('.mdCMN38Item01Ttl').innerText
let firstStickerID = document.querySelector('.mdCMN09Image').style['background-image'].match(/sticker\/(\d+)/)[1]
let length = document.querySelectorAll('.mdCMN09Li').length
let append_string = 'lineemotes.appendPack(`' + title + '`, ' + firstStickerID + ', ' + length + ')'
let strings = getStrings()
let inlineCSS = `
background: #2e3136;
padding: 1em;
-webkit-border-radius: 3px;
border-radius: 3px;
font-family: Consolas, "Liberation Mono", Menlo, Courier, monospace;
line-height: 16px;
color: rgba(255,255,255,.7);
margin: 10px 0;`

// Output to console
console.log(
`${strings['title']}: ${title}
${strings['firstID']}: ${firstStickerID}
${strings['count']}: ${length}
${strings['append']}:
${append_string}`)

// Output on page
let output = document.createElement('p')
output.appendChild(document.createTextNode(`${strings['title']}: ${title}`))
output.appendChild(document.createElement('br'))
output.appendChild(document.createTextNode(`${strings['firstID']}: ${firstStickerID}`))
output.appendChild(document.createElement('br'))
output.appendChild(document.createTextNode(`${strings['count']}: ${length}`))
output.appendChild(document.createElement('br'))
output.appendChild(document.createTextNode(`${strings['append']}:`))
output.appendChild(document.createElement('br'))
output.appendChild(document.createTextNode(`${append_string}`))
output.style = inlineCSS

document.querySelector('.mdCMN38Item01').appendChild(output)