Working popup
							parent
							
								
									750b68fa24
								
							
						
					
					
						commit
						4070fac3e0
					
				| @ -0,0 +1,3 @@ | ||||
| <button id="clean">clean memory</button> | ||||
| <div id="output"></div> | ||||
| <script src="popup.js"></script> | ||||
| @ -0,0 +1,29 @@ | ||||
| output.innerHTML = "loading..."; | ||||
| let tabid = null; | ||||
| chrome.tabs.query({ active: true, currentWindow: true }, function (tabs) { | ||||
|   var currTab = tabs[0]; | ||||
|   if (currTab) { | ||||
|     // Sanity check
 | ||||
|     /* document.write(JSON.stringify(currTab)); */ | ||||
|     tabid = currTab.id; | ||||
|   } | ||||
| }); | ||||
| 
 | ||||
| function render(memory = {}) { | ||||
|   let output_txt = ""; | ||||
|   if (!memory?.[tabid]) { | ||||
|     output_txt = "No data for this tab"; | ||||
|   } | ||||
|   Object.keys(memory[tabid]).forEach( | ||||
|     (host) => (output_txt += /* HTML */ `${host}</br>`) | ||||
|   ); | ||||
|   output.innerHTML = output_txt; | ||||
| } | ||||
| 
 | ||||
| chrome.runtime.sendMessage({ msg: "get_memory" }, (memory) => { | ||||
|   render(memory); | ||||
| }); | ||||
| 
 | ||||
| clean.onclick = () => { | ||||
|   chrome.runtime.sendMessage({ msg: "clear_memory" }, render); | ||||
| }; | ||||
					Loading…
					
					
				
		Reference in New Issue