ffactory / Intercom videos inline

// ==UserScript==
// @name         Intercom videos inline
// @namespace    http://tampermonkey.net/
// @version      0.2
// @description  Adds inline video preview to intercom conversations (for .mp4, .mov)
// @author       You
// @match        https://app.intercom.com/a/inbox/eqi2cjhr/inbox/shared/all/conversation/*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=intercom.com
// @grant        none
// @updateURL https://openuserjs.org/meta/ffactory/Intercom_videos_inline.meta.js 
// @downloadURL https://openuserjs.org/install/ffactory/Intercom_videos_inline.user.js
// @copyright 2022, ffactory (https://openuserjs.org/users/ffactory)
// @license MIT
// ==/UserScript==

(function () {
  'use strict';
  setInterval(function () {
    document.querySelectorAll(".embercom-prosemirror-composer-attachment a").forEach(function (el) {
      if (el.href && (el.href.includes(".mp4") || el.href.includes(".mov")) && el.childElementCount == 0) {
        var v = document.createElement("video");
        v.controls = true;
        v.preload = "none";
        v.poster = "";
        v.src = el.href;
        v.style.maxHeight = "500px";
        el.append(v);
      }
    });
  }, 500);

})();