Pen Settings



CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ add another resource


Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource


Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.


Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.


      , v-show="ready")
  .alert.alert-danger#error(role="alert", v-show="error")
    pre.mb-0 {{ error }}
    button.close(type="button", @click="error = ''") #[span &times;]
  h1 LINE 訊息推送工具
        label(for="proxy") API Proxy
        label(for="csv") CSV 網址 (第一列會成為變數名稱)
        label(for="access-token") Access Token
        input#access-token.form-control.form-control-sm(type="password", v-model="i.accessToken")
        label(for="to") 傳送給 (可使用變數)
    label(for="msg") 訊息內容 JSON (先處理變數才會轉 JSON,務必注意 JSON escape 的問題)
    textarea#msg.form-control.form-control-sm.h-400px(v-model="i.msg"), v-if="status") {{ status }}…"button", @click="linePush", v-else) 推送訊息"", target="_blank") template 文件"", target="_blank") Flex 模擬器"", target="_blank") Flex 模擬器 β"", target="_blank") LINE 訊息文件


  display: none
  height: 400px !important
  position: fixed
  bottom: 0
  z-index: 1071
  left: 1rem
  right: 1rem
    position: absolute
    right: 1.25rem
    top: .75rem


                const sleep = wait => new Promise(resolve => setTimeout(resolve, wait))

let vm = new Vue({
  el: '#app',
  data: {
    i: {
      accessToken: '',
      csv: '',
      msg: '',
      proxy: '',
      to: '',
    ready: false,
    status: '',
    error: ''
  async mounted () {
    try {
      let saved = JSON.parse(localStorage.getItem('zYYMrLb'))
      if (saved) this.$set(this, 'i', {...this.i, ...saved})
    } catch (err) {}
    this.$watch('i', (newVal, oldVal) => {
      localStorage.setItem('zYYMrLb', JSON.stringify(this.i))
    }, { deep: true })
    this.ready = true
  methods: {
    async linePush () {
      const errors = []
      try {
        // 取得 csv
        this.status = '正在從 csv 取得資料'
        const rows = await this.getCsv(this.i.csv)
        console.log(`成功從 csv 中取得 ${rows.length} 筆資料`)
        if (rows.length <= 0) throw new Error('csv 中沒有任何記錄')

        // 推送確認
        this.status = '等候使用者確認推送'
        await sleep(100)
        if (!confirm(`即將推送 ${rows.length} 則訊息!`)) throw new Error('使用者自行取消推送')

        // compile tpl
        this.status = '正在解析訊息內容 JSON'
        const tplTo = _.template(
        const tplMsg = _.template(this.i.msg)
        let sendCnt = 0
        for (const item of rows) {
          try {
            this.status = `正在傳送訊息 (${++sendCnt} / ${rows.length})`
            const to = tplTo({...item, _})
            const msg = JSON.parse(tplMsg({...item, _}))
            await this.pushMessage(to, msg)
          } catch (err) {
            err.message = `${this.status} ${err.message}`
      } catch (err) {
      this.error =, err => err.message).join('\n')
      this.status = ''
    async getCsv (url) {
      url = new URL(url)
      url.searchParams.set('cachebust', +new Date())
      const csv = _.trim(_.get(await axios.get(url.href), 'data'))
      return _.get(Papa.parse(csv, {
        encoding: 'utf8',
        header: true,
      }), 'data', [])
    async pushMessage (to, messages, notificationDisabled = false) {
      try {
        if (!_.isArray(messages)) messages = [messages]
        await, {
        }, {
          headers: {
            Authorization: `Bearer ${this.i.accessToken}`
      } catch (err) {
        if (_.hasIn(err, 'response')) {
          const res = err.response
          const debugObj = {status: res.status, headers: res.headers, data:, to, messages}
          err.stack = `${}: LINE pushMessage failed with status code ${res.status}\n${JSON.stringify(debugObj, null, 2)}`
        throw err