Benoit Sida 4 år sedan
förälder
incheckning
1c8ef5e2ec
4 ändrade filer med 30 tillägg och 2 borttagningar
  1. Binär
      PasteTab.crx
  2. 3
    0
      pack
  3. 22
    1
      src/scripts/background.js
  4. 5
    1
      src/scripts/oncopy.js

Binär
PasteTab.crx Visa fil


+ 3
- 0
pack Visa fil

@@ -7,6 +7,7 @@ if test $# -ne 2; then
7 7
     exit 1
8 8
 fi
9 9
 
10
+min="$1"_tmp
10 11
 dir=$1
11 12
 key=$2
12 13
 name="PasteTab"
@@ -16,6 +17,8 @@ sig="$name.sig"
16 17
 zip="$name.zip"
17 18
 trap 'rm -f "$pub" "$sig" "$zip"' EXIT
18 19
 
20
+# recursively minify js and css
21
+
19 22
 # zip up the crx dir
20 23
 cwd=$(pwd -P)
21 24
 (cd "$dir" && zip -qr -9 -X "$cwd/$zip" .)

+ 22
- 1
src/scripts/background.js Visa fil

@@ -1 +1,22 @@
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);
1
+var result = '';
2
+
3
+function getContentFromClipboard() {
4
+    var sandbox = document.getElementById('sandbox');
5
+    sandbox.value = '';
6
+    sandbox.select();
7
+    if (document.execCommand('paste'))
8
+	result = sandbox.value;
9
+    chrome.browserAction.setBadgeText({text: result.length.toString() });
10
+    return result;
11
+}
12
+
13
+function onClickHandler() {
14
+    window.open().document.write('<pre>' + getContentFromClipboard() + '</pre>');
15
+}
16
+
17
+chrome.runtime.onMessage.addListener(function (request, sender, sendResponse) {
18
+    if (request.event == 'copy') getContentFromClipboard();
19
+});
20
+
21
+chrome.browserAction.setBadgeText({ text: '' });
22
+chrome.browserAction.onClicked.addListener(onClickHandler);

+ 5
- 1
src/scripts/oncopy.js Visa fil

@@ -1 +1,5 @@
1
-"use strict";function onCopy(a){chrome.runtime.sendMessage({event:"copy"})}document.addEventListener("copy",onCopy,!0);
1
+function onCopy(e) {
2
+    chrome.runtime.sendMessage({event:"copy"});
3
+}
4
+
5
+document.addEventListener("copy", onCopy, true);