Minimal Chrome extension (8ko) that output the content of clipboard to a new tab

background.js 562B

1
  1. "use strict";function getContentFromClipboard(){var a=document.getElementById("sandbox");return a.value="",a.select(),document.execCommand("paste")&&(result=a.value),a.value="",chrome.browserAction.setBadgeText({text:result.length.toString()}),result}function onClickHandler(){var a=getContentFromClipboard(),b=window.open();b.document.write(a)}var result="";chrome.runtime.onMessage.addListener(function(a,b,c){"copy"==a.event&&getContentFromClipboard()}),chrome.browserAction.setBadgeText({text:""}),chrome.browserAction.onClicked.addListener(onClickHandler);