Files
webextensions-examples/user-agent-rewriter/popup/choose_ua.js
rebloor 82217a05bc Replace var with let in examples (#484)
* Replace var with let in examples

store-collected-images/webextension-plain/deps/uuidv4.js

* Reverted third–party code
2022-08-11 04:27:28 +12:00

16 lines
446 B
JavaScript

/*
If the user clicks on an element which has the class "ua-choice":
* fetch the element's textContent: for example, "IE 11"
* pass it into the background page's setUaString() function
*/
document.addEventListener("click", (e) => {
if (!e.target.classList.contains("ua-choice")) {
return;
}
let chosenUa = e.target.textContent;
let backgroundPage = browser.extension.getBackgroundPage();
backgroundPage.setUaString(chosenUa);
});