mirror of
https://github.com/mdn/webextensions-examples.git
synced 2026-04-29 20:37:01 +02:00
Unbeastifying methods
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
/*
|
||||
clear():
|
||||
* either reloads or clears the page depending on the request
|
||||
*/
|
||||
function clear(request, sender, sendResponse) {
|
||||
switch (request.type){
|
||||
case "Reload":
|
||||
location.reload();
|
||||
break;
|
||||
case "Blank":
|
||||
removeEverything();
|
||||
break;
|
||||
}
|
||||
|
||||
chrome.runtime.onMessage.removeListener(clear);
|
||||
}
|
||||
|
||||
function removeEverything() {
|
||||
while (document.body.firstChild) {
|
||||
document.body.firstChild.remove();
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
Assign clear() as a listener for messages from the extension.
|
||||
*/
|
||||
chrome.runtime.onMessage.addListener(clear);
|
||||
Reference in New Issue
Block a user