LINE Append String

Automatic generation of append string for BetterDiscord plugin

当前为 2018-10-20 提交的版本,查看 最新版本

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==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.2
// @grant       none
// @run-at      document-end
// ==/UserScript==

(function() {
    'use strict';

    var title = document.querySelector('.mdCMN08Ttl').innerHTML;
    var firstStickerID = document.querySelector('.mdCMN09Image').style['background-image'].match(/sticker\/(\d+)/)[1];
    var length = document.querySelectorAll('.mdCMN09Li').length.toString();
    var animated = Boolean(document.querySelector('.MdIcoPlay_b'));
    var append_string = 'maganeAppendPack(`' + title + '`, ' + firstStickerID + ', ' + length + ', ' + (animated ? 1 : 0) + ')';

    var href = window.location.pathname.split('/');
    var locale = href[href.length - 1]

    var strings = {
        'title' : 'Title',
        'count': 'Sticker count',
        'first_id': 'First sticker ID',
        'animated': 'Animated',
        'append': 'Console command'
    }
    if (locale === 'ja') {
        strings = {
            'title' : 'タイトル',
            'count': 'スタンプの数',
            'first_id': '最初のスタンプID',
            'append': '追加のコマンド'
        }
    }

    var inlineCSS = `background: #2e3136;
padding: 1em;
-webkit-border-radius: 3px;
border-radius: 3px;
font-family: monospace;
line-height: 16px;
color: rgba(255,255,255,.7);
margin: 10px 0;`;

    console.log(`${strings['title']}: ${title}
${strings['first_id']}: ${firstStickerID}
${strings['count']}: ${length}
${strings['animated']}: ${String(animated)}
${strings['append']}:
${append_string}`);

    document.querySelector('.mdCMN08Txt').innerHTML += `<p style='${inlineCSS}'>
${strings['title']}: ${title}<br>
${strings['first_id']}: ${firstStickerID}<br>
${strings['count']}: ${length}<br>
${strings['animated']}: ${String(animated)}<br>
${strings['append']}: <br>
${append_string}
</p>`;
})();