Browse Source

优化jsonformat的功能,修复contentType不为json情况下的bug

Alien 12 years ago
parent
commit
4ee0e5052a

+ 1 - 1
chrome/manifest.json

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

+ 1 - 1
chrome/online.manifest.json

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

+ 16 - 8
chrome/static/js/jsonformat/contentscript-jsonformat.js

@@ -26,16 +26,24 @@ baidu.csJsonFormat = (function(){
 
 	var _init = function(){
 		$(function(){
-            var source = $.trim($('body>pre').html());
+            var source = $.trim($('body>pre').html()) || $.trim($('body').html());
+            var isJson = true;
+            var jsonObj = null;
             try{
-                var obj = JSON.parse(source);
-                if(obj != null) {
-                    $('body').html(_htmlFragment);
-                    _loadCss();
-                    JsonFormatEntrance.clear();
-                    JsonFormatEntrance.format(source);
-                }
+                jsonObj = JSON.parse(source);
             }catch(ex){
+                isJson = false;
+                try{
+                    jsonObj = new Function("return " + source)();
+                    isJson = true;
+                }catch(ex){
+                }
+            }
+            if(isJson && jsonObj) {
+                $('body').html(_htmlFragment);
+                _loadCss();
+                JsonFormatEntrance.clear();
+                JsonFormatEntrance.format(source);
             }
 		});
 	};

File diff suppressed because it is too large
+ 0 - 0
chrome/template/fehelper_wpo.html


Some files were not shown because too many files changed in this diff