mirror of
https://github.com/mdn/webextensions-examples.git
synced 2026-04-16 06:18:35 +02:00
16 lines
451 B
JavaScript
16 lines
451 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", function(e) {
|
|
if (!e.target.classList.contains("ua-choice")) {
|
|
return;
|
|
}
|
|
|
|
var chosenUa = e.target.textContent;
|
|
var backgroundPage = browser.extension.getBackgroundPage();
|
|
backgroundPage.setUaString(chosenUa);
|
|
});
|