js doc and code optimize
This commit is contained in:
		| @ -1,15 +1,23 @@ | ||||
| chrome.runtime.onMessage.addListener( | ||||
|     function (request, sender, sendResponse) { | ||||
|         // console.log(request); | ||||
|         if (request.from == "DataExtracter:Extract") { | ||||
|             let data = extractData(request.itemsSelector, request.fieldSelectors); | ||||
|             if (sendResponse) sendResponse(data); | ||||
|         } else if (request.from == "DataExtracter:GotoUrl") { | ||||
|             window.location.replace(request.url); | ||||
|         } else if (request.from == "DataExtracter:ReportIn") { | ||||
|             if (sendResponse) sendResponse(request.from); | ||||
|         } else if (request.from == "DataExtracter:QueryUrl") { | ||||
|             if (sendResponse) sendResponse(window.location.href); | ||||
|         switch (request.from) { | ||||
|             case "DataExtracter:Extract": | ||||
|                 let data = extractData(request.itemsSelector, request.fieldSelectors); | ||||
|                 if (sendResponse) sendResponse(data); | ||||
|                 break; | ||||
|             case "DataExtracter:GotoUrl": | ||||
|                 window.location.replace(request.url); | ||||
|                 if (sendResponse) sendResponse(request.url); | ||||
|                 break; | ||||
|             case "DataExtracter:ReportIn": | ||||
|                 if (sendResponse) sendResponse(request.from); | ||||
|                 break; | ||||
|             case "DataExtracter:QueryUrl": | ||||
|                 if (sendResponse) sendResponse(window.location.href); | ||||
|                 break; | ||||
|             default: | ||||
|                 break; | ||||
|         } | ||||
|     } | ||||
| ); | ||||
| @ -49,12 +57,9 @@ function extract(itemsSelector:string, fieldSelectors:string, url:string, pages: | ||||
| } | ||||
|  | ||||
| function testArgs(...args) { | ||||
|  | ||||
|     if (args.length < 2) return false; | ||||
|  | ||||
|     if (args.length == 2) | ||||
|         return (args[0] && args[1] && (typeof args[0] == "string") && (args[1] instanceof Array)) | ||||
|  | ||||
|     let urls = []; | ||||
|     if (args.length > 2) return (typeof args[2] == "string") && ( | ||||
|         (args[3] instanceof Array) || | ||||
|  | ||||
		Reference in New Issue
	
	Block a user