mirror of
https://github.com/mdn/webextensions-examples.git
synced 2026-05-06 07:37:53 +02:00
extension work
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
html, body {
|
||||
height: 100px;
|
||||
width: 300px;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.action {
|
||||
height: 30%;
|
||||
width: 90%;
|
||||
margin: 3% auto;
|
||||
padding-top: 6%;
|
||||
text-align: center;
|
||||
font-size: 1.5em;
|
||||
background-color: #E5F2F2;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.action:hover {
|
||||
background-color: #CFF2F2;
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
<!DOCTYPE html>
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<link rel="stylesheet" href="choose_action.css"/>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div class="action">highlight-para</div>
|
||||
<div class="action">show-foo</div>
|
||||
<div class="action">call-confirm</div>
|
||||
<script src="choose_action.js"></script>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
@@ -0,0 +1,11 @@
|
||||
|
||||
document.addEventListener("click", function(e) {
|
||||
if (!e.target.classList.contains("action")) {
|
||||
return;
|
||||
}
|
||||
|
||||
var chosenAction = e.target.textContent;
|
||||
chrome.tabs.query({active: true, currentWindow: true}, function(tabs) {
|
||||
chrome.tabs.sendMessage(tabs[0].id, {name: chosenAction});
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user