瀏覽代碼

JSON格式化工具优化

zxlie 9 年之前
父節點
當前提交
28755d41d1
共有 3 個文件被更改,包括 8 次插入5 次删除
  1. 1 1
      chrome/manifest.json
  2. 1 1
      chrome/online.manifest.json
  3. 6 3
      chrome/static/js/jsonformat/contentscript-jsonformat.js

+ 1 - 1
chrome/manifest.json

@@ -1,6 +1,6 @@
 {
     "name": "WEB前端助手(FeHelper)",
-    "version": "8.0",
+    "version": "8.1",
     "manifest_version": 2,
 
     "default_locale": "zh_CN",

+ 1 - 1
chrome/online.manifest.json

@@ -1,6 +1,6 @@
 {
     "name": "WEB前端助手(FeHelper)",
-    "version": "8.0",
+    "version": "8.1",
     "manifest_version": 2,
 
     "default_locale": "zh_CN",

+ 6 - 3
chrome/static/js/jsonformat/contentscript-jsonformat.js

@@ -7,9 +7,6 @@ baidu.csJsonFormat = (function () {
 
     var _htmlFragment = [
         '<div class="mod-json mod-contentscript"><div class="rst-item">',
-        '<div id="formatTips">本页JSON数据由FeHelper进行自动格式化,若有任何问题,点击这里提交 ',
-        '<a href="http://www.baidufe.com/fehelper/feedback.html" target="_blank">意见反馈</a>',
-        '</div>',
         '<div id="formattingMsg">',
         '<svg id="spinner" width="16" height="16" viewBox="0 0 300 300" xmlns="http://www.w3.org/2000/svg" version="1.1">',
         '<path d="M 150,0 a 150,150 0 0,1 106.066,256.066 l -35.355,-35.355 a -100,-100 0 0,0 -70.711,-170.711 z" fill="#3d7fe6"></path>',
@@ -145,6 +142,12 @@ baidu.csJsonFormat = (function () {
                 if(newSource.length * 2 < (_uniDecode(source)).length) {
                     return ;
                 }
+                // 直接replace掉所有\w之外的字符,再和原内容比较
+                var r_ns = newSource.replace(/[^\w]/gm,'');
+                var r_os = _uniDecode(source).replace(/[^\w]/gm,'');
+                if(r_ns < r_os) {
+                    return ;
+                }
             } catch (ex) {
                 // 通过JSON反解不出来的,一定有问题
                 return;