zxlie 8 年之前
父節點
當前提交
c9d6e2ebf1
共有 2 個文件被更改,包括 15 次插入14 次删除
  1. 14 13
      v2.0/apps/background/index.js
  2. 1 1
      v2.0/apps/qr-code/index.js

+ 14 - 13
v2.0/apps/background/index.js

@@ -220,7 +220,7 @@ var BgPageInstance = (function () {
                     }).toString() + ')(' + JSON.stringify(info) + ')',
                     allFrames: false
                 }, function (txt) {
-                    _openFileAndRun(tab, MSG_TYPE.QR_CODE, txt);
+                    _openFileAndRun(tab, MSG_TYPE.QR_CODE, txt[0]);
                 });
             }
         });
@@ -264,12 +264,13 @@ var BgPageInstance = (function () {
             parentId: feHelper.contextMenuId,
             onclick: function (info, tab) {
                 chrome.tabs.executeScript(tab.id, {
-                    code: '(' + (function () {
-                        return window.getSelection().toString();
-                    }).toString() + ')()',
+                    code: '(' + (function (pInfo) {
+
+                        return pInfo.selectionText;
+                    }).toString() + ')(' + JSON.stringify(info) + ')',
                     allFrames: false
                 }, function (txt) {
-                    _openFileAndRun(tab, MSG_TYPE.EN_DECODE, txt);
+                    _openFileAndRun(tab, MSG_TYPE.EN_DECODE, txt[0]);
                 });
             }
         });
@@ -284,12 +285,12 @@ var BgPageInstance = (function () {
             parentId: feHelper.contextMenuId,
             onclick: function (info, tab) {
                 chrome.tabs.executeScript(tab.id, {
-                    code: '(' + (function () {
-                        return window.getSelection().toString();
-                    }).toString() + ')()',
+                    code: '(' + (function (pInfo) {
+                        return pInfo.selectionText;
+                    }).toString() + ')(' + JSON.stringify(info) + ')',
                     allFrames: false
                 }, function (txt) {
-                    _openFileAndRun(tab, MSG_TYPE.JSON_FORMAT, txt);
+                    _openFileAndRun(tab, MSG_TYPE.JSON_FORMAT, txt[0]);
                 });
             }
         });
@@ -304,12 +305,12 @@ var BgPageInstance = (function () {
             parentId: feHelper.contextMenuId,
             onclick: function (info, tab) {
                 chrome.tabs.executeScript(tab.id, {
-                    code: '(' + (function () {
-                        return window.getSelection().toString();
-                    }).toString() + ')()',
+                    code: '(' + (function (pInfo) {
+                        return pInfo.selectionText;
+                    }).toString() + ')(' + JSON.stringify(info) + ')',
                     allFrames: false
                 }, function (txt) {
-                    _openFileAndRun(tab, MSG_TYPE.CODE_BEAUTIFY, txt);
+                    _openFileAndRun(tab, MSG_TYPE.CODE_BEAUTIFY, txt[0]);
                 });
             }
         });

+ 1 - 1
v2.0/apps/qr-code/index.js

@@ -17,7 +17,7 @@ new Vue({
             if (request.type === MSG_TYPE.TAB_CREATED_OR_UPDATED && request.event === MSG_TYPE.QR_CODE) {
                 if (request.content) {
                     this.textContent = request.content;
-                    this.$nextTick(this.convert);
+                    this.convert();
                 }
             }
         });