function copyToClipboard (copytext) { const supstr = Components.classes["@mozilla.org/supports-string;1"]. createInstance(Components.interfaces.nsISupportsString); const transferable = Components.classes["@mozilla.org/widget/transferable;1"]. createInstance(Components.interfaces.nsITransferable); const iClipboard = Components.interfaces.nsIClipboard; const clipboard = Components.classes["@mozilla.org/widget/clipboard;1"]. getService(iClipboard); supstr.data = copytext; transferable.addDataFlavor("text/unicode"); transferable.setTransferData("text/unicode", supstr, copytext.length * 2); return clipboard.setData(transferable, null, iClipboard.kGlobalClipboard); } copyToClipboard('hogehoge');