Skip to content

Instantly share code, notes, and snippets.

@justsml
Created October 24, 2024 09:51
Show Gist options
  • Save justsml/f29ebc040e564fb1b33f13c8ed2634be to your computer and use it in GitHub Desktop.
Save justsml/f29ebc040e564fb1b33f13c8ed2634be to your computer and use it in GitHub Desktop.

Revisions

  1. justsml created this gist Oct 24, 2024.
    28 changes: 28 additions & 0 deletions SLACK-EMOJI-RAPID-UPLOAD.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,28 @@
    // This script makes it very fast to drag and drop files into the Slack Emoji Admin page
    var isModalOpen = () => Boolean(document.querySelector('.ReactModal__Content--after-open'))

    function openModal() {
    var addBtn = document.querySelector('[data-qa="customize_emoji_add_button"]')
    // modal closed, open it again
    if (addBtn) addBtn.click()
    }

    var $timer = setInterval(() => {
    if (isModalOpen()) {
    var visibleForm = document.querySelector('.p-add_custom_emoji_dialog__form')
    if (visibleForm) {
    // clearInterval($timer)
    var fileName = document.querySelector('.p-add_custom_emoji_dialog__filename')?.innerHTML;
    if (fileName) {
    // auto save!
    var saveModalButton = document.querySelector('[data-qa="customize_emoji_add_dialog_go"]')
    saveModalButton.click()
    // auto open, fast
    setTimeout(openModal, 120)
    }
    }
    } else {
    openModal()
    }
    }, 100);

    16 changes: 16 additions & 0 deletions gather-emojis.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,16 @@
    // 1. Run in console on slack emoji admin page,
    // 2. scroll your entire list
    // 3. when done run `stopCapture()` for your Emoji names + URLs
    var emojis = {};
    var $timer = setInterval(captureEmojis, 50);

    function captureEmojis() {
    document.querySelectorAll(".p-customize_emoji_list__image").forEach((el) => {
    emojis[el.alt] = el.src;
    });
    }

    function stopCapture() {
    clearInterval($timer);
    console.dir(emojis);
    }