tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

clipboard.js (634B)


      1 /* This Source Code Form is subject to the terms of the Mozilla Public
      2 * License, v. 2.0. If a copy of the MPL was not distributed with this
      3 * file, You can obtain one at <http://mozilla.org/MPL/2.0/>. */
      4 
      5 /**
      6 * Clipboard function taken from
      7 * https://searchfox.org/mozilla-central/source/devtools/shared/platform/clipboard.js
      8 */
      9 
     10 export function copyToTheClipboard(string) {
     11  const doCopy = function (e) {
     12    e.clipboardData.setData("text/plain", string);
     13    e.preventDefault();
     14  };
     15 
     16  document.addEventListener("copy", doCopy);
     17  document.execCommand("copy", false, null);
     18  document.removeEventListener("copy", doCopy);
     19 }