Raw
 1(function () {
 2  "use strict";
 3
 4  function each(selector, root, fn) {
 5    Array.prototype.forEach.call((root || document).querySelectorAll(selector), fn);
 6  }
 7
 8  if (navigator.clipboard && window.isSecureContext) {
 9    each("button[data-copy]", null, function (button) {
10      var source = document.getElementById(button.getAttribute("data-copy"));
11      if (!source) {
12        return;
13      }
14      button.hidden = false;
15      button.addEventListener("click", function () {
16        navigator.clipboard.writeText(source.textContent.trim()).then(function () {
17          button.setAttribute("data-copied", "");
18        }, function () {
19          button.removeAttribute("data-copied");
20        });
21      });
22    });
23  }
24
25  each("form", null, function (form) {
26    form.addEventListener("submit", function () {
27      each("button[data-disable-on-submit]", form, function (button) {
28        button.disabled = true;
29      });
30    });
31  });
32
33  window.addEventListener("pageshow", function () {
34    each("button[data-disable-on-submit]", null, function (button) {
35      button.disabled = false;
36    });
37  });
38})();