availablity check before run on active tab
This commit is contained in:
		| @ -110,16 +110,17 @@ function extractTabData(tab, itemsSelector, fieldSelectors) { | ||||
| } | ||||
|  | ||||
| /** | ||||
|  * get report in from the target tab, usually used to detect if the content script is ready. | ||||
|  * ping target tab, usually used to detect if the content script is ready. | ||||
|  * @param {any} tab target tab | ||||
|  * @returns {Promise<string>} a promise of the report in message | ||||
|  * @returns {Promise<boolean>} a promise of boolean value indicates if ping success | ||||
|  */ | ||||
| function reportIn(tab) { | ||||
| async function ping(tab, count = 1) { | ||||
|     let req = { | ||||
|         action: ACTION_REPORT_IN | ||||
|     } | ||||
|     let cond = r => r == req.action; | ||||
|     return sendMessage(tab, req, 'Check tab availability...', cond); | ||||
|     let pong = await sendMessage(tab, req, 'Check tab availability...', cond, 1000, count).catch(() => { }); | ||||
|     return pong == ACTION_REPORT_IN; | ||||
| } | ||||
|  | ||||
| /** | ||||
|  | ||||
		Reference in New Issue
	
	Block a user