WME E97 Copy address button

One button and one shortcut for copy POI address

// ==UserScript==
// @name         WME E97 Copy address button
// @name:uk      WME 🇺🇦 E97 Copy address button
// @version      0.3.0
// @description  One button and one shortcut for copy POI address
// @description:uk Це лише кнопка, щоб копіювати адресу обраного POI
// @license      MIT License
// @author       Anton Shevchuk
// @namespace    https://greasyfork.org/users/22648-anton-shevchuk
// @supportURL   https://github.com/AntonShevchuk/wme-e97/issues
// @match        https://*.waze.com/editor*
// @match        https://*.waze.com/*/editor*
// @exclude      https://*.waze.com/user/editor*
// @icon         data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAYAAACqaXHeAAAYjXpUWHRSYXcgcHJvZmlsZSB0eXBlIGV4aWYAAHja7ZtZchy7smz/MYo7hEQPDAet2Z3BG/5dDhQpSptUt8/fO6KJVZWZhS4iPNwDoFn/73+3+R/+Fe+DCTGXVFN6+BdqqK7xpjz33321Tzi/z7/wusXn766b9xuOS55Xfz+m9Xq+cT1++0J+fcH276+bPF7tlFdD9r3h88+rZ72fr0G+GvLuXrevz6a+vtDSh+m8/rvxavbV+I+fQ2YxZqQ974xb3vrn/Ha3J88ofPVN1/ntPDd4b8+VdK7kf66feV+6Txbw/d0P6/e8jcx/W47b0Nu00g/r9Lpu4w/X/Xs37rsRWffes/s4ohztfj7++7B+e8+y97qzayEZliu9JvU2lfOOBzvL6c/XEj+Z/5H3+fxUfsrTnoHVJlPt5ul8qNaxstsGO22z267zOuxgiMEtl3l1bjh/rhWfXXXjGCXox26XDfaZvmCJgeVwde/ex2JPv1X90Vmh52l50lkaw8bf/5gfL/ztz3cN7S03t/Yp72vFuJz8i2HIcvrNUxjkZQaFie5Yc1+eH//JsB4LxrPMhQm2p98merTffMsfO/snGh4Nr5C2eb4aYInoOzIYPDrYJ1kfbbJPdi5byzoW7NMYufPBdSxgo4luMkoXvE8Ypzj1zXeyPc+66O5l4AVDREIkYxoCCGOFEEMi3gou1Ez0McQYU8yxxBpb8imkmFLKSTjVss8hx5xyzi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ABa3rUgsCgQzCImjq48irdjb3Hu73OEnmWlWc9H34xq9bOOt44kFzYWfhkEEHMW75EiTSHd28PZAyOGkWa6ve6Ytm2cXRypSJL1yj558LGgCIixi4GnrSdaFa0433aepNvqtpUkN3c0T+sjcFUgeYPW1TZ/2+HZIsImAtnfZxNveGmnFOcvawiwoFuQ3uoAcKvp1vSHJnY8kvxS/nL+CGBbsVEQqP+JTY44ByX9JcjrzUPamzRYmI2f661csRLFm4ux+4/d8Df3R8p3KaR6XtopRYGiQGs1SiKgZx4JsGfbQ8jWfxUQt4tR0l8CAKh9XosQrxBCt02wDcOC4emJE2nfzlqakzdJ5R3lX8aRWPKdZAyoBnTaVT2pwqmWU1r1k6s/AKgfqf8yCLg3cg+Hcw+jf6hfq03l40oE3AzQ7kT9+caj1xSobK6Eckg5604aXzeST25eXUHTz0044HUAbg5uYC9jQzWiwivFKxQ/KsaF9gs6fV6vuk5c02iz/7hD46Xw1C8SXowLSTQY/IciNaBOHk+hVT+tAl0yKiFOJSI5kTB0TI5RMioZowOomTioiPONM3gCJmL8GHMNE0BeaUOpf/TmaPh5+KGaVm24P0h4R8B3jS8AoLShFADyFv0vMgxUAgjArYxnGQKnd04OtstsYW5qbpCBy5VyFNYUIrQ0tBbATpzEEPWbHAUKFChQoECBAgUKFBYl/gO88/2Hifn4nQAAAABJRU5ErkJggg==
// @grant        GM.setClipboard
// @require      https://update.greasyfork.org/scripts/450160/1218867/WME-Bootstrap.js
// @require      https://update.greasyfork.org/scripts/452563/1218878/WME.js
// @require      https://update.greasyfork.org/scripts/450221/1137043/WME-Base.js
// @require      https://update.greasyfork.org/scripts/450320/1281847/WME-UI.js
// ==/UserScript==

/* jshint esversion: 8 */
/* global require */
/* global $, jQuery */
/* global W */
/* global I18n */
/* global WME, WMEBase, WMEUI, WMEUIHelper, WMEUIShortcut */

(function () {
  'use strict'

  const NAME = 'E97'

  // translation structure
  const TRANSLATION = {
    'en': {
      title: 'Copy address',
      description: 'Copy name and address of the selected POI to clipboard',
    },
    'uk': {
      title: 'Копіювати адресу',
      description: 'Копіювати до буферу обміну назву та адресу обраного POI',
    }
  }

  const STYLE = '.e97 { float: right; z-index: 100; top: 0; right: 0; margin: 0 1px; border: 0; background: none; }'

  WMEUI.addTranslation(NAME, TRANSLATION)
  WMEUI.addStyle(STYLE)

  class E97 extends WMEBase {
    constructor (name) {
      super(name)

      this.createButton()

      this.createShortcut()
    }

    /**
     * Handler for `venue.wme` event
     * @param {jQuery.Event} event
     * @param {HTMLElement} element
     * @param {W.model} model
     * @return {Null}
     */
    onVenue(event, element, model) {
      if (element.querySelector('div.external-providers-control > wz-label')) {
        element.querySelector('div.external-providers-control > wz-label').append(this.button)
      }
    }

    /**
     * Create `copy` button for external providers
     */
    createButton () {
      let icon = document.createElement('i')
      icon.className = 'fa fa-copy w-clickable'

      this.button = document.createElement('button')
      this.button.className = 'e97'
      this.button.title = I18n.t(NAME).title
      this.button.append(icon)
      this.button.onclick = () => this.copyAddress()
    }

    /**
     * Create the shortcut
     * Uses WMEUI library
     */
    createShortcut () {
      WMEUI.addShortcut(
        NAME + '-copy', // name
        I18n.t(NAME).description, // description
        NAME, // group
        I18n.t(NAME).title, // title
        'C+D', // shortcut
        () => this.copyAddress(), // callback
      )
    }

    /**
     * Copy the venue address to the clipboard
     * @return {boolean}
     */
    copyAddress () {
      let poi = WME.getSelectedVenue()
      if (!poi) {
        return false
      }

      let parts = [
        poi.getAddress().getHouseNumber(),
        poi.getAddress().getStreet().getName(),
        poi.getAddress().getCity().getName(),
      ]

      let text = parts.filter(el => el != null).join(', ')

      GM.setClipboard(text)

      this.log('copied "' + text + '"')

      $('wz-button.external-provider-add-new').click()
      return false
    }
  }

  $(document).on('bootstrap.wme', () => new E97(NAME))
})();