Skip to content

Commit bcabed9

Browse files
authored
Merge pull request #80 from kiacolbert/pageAction
Page action
2 parents 8fabb46 + cd4aa6e commit bcabed9

File tree

4 files changed

+42
-12
lines changed

4 files changed

+42
-12
lines changed

src/browser/chrome/icon.png

60.1 KB
Loading

src/browser/chrome/manifest.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44
"description": "Time travel",
55
"manifest_version": 2,
66
"page_action": {
7+
"default_icon": {
8+
"32": "icon.png"
9+
},
710
"default_popup": "page_action.html"
811
},
912
"background": {
@@ -24,7 +27,7 @@
2427
"webRequestBlocking"
2528
],
2629
"web_accessible_resources": [
27-
"scripts/deepclone_bundle.js"
30+
"scripts/deepclone_bundle.js"
2831
],
2932
"devtools_page": "devtools.html"
3033
}

src/browser/chrome/page_action.html

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,35 @@
55
<meta name="viewport" content="width=device-width, initial-scale=1.0">
66
<meta http-equiv="X-UA-Compatible" content="ie=edge">
77
<title>Page Action</title>
8+
<script src="links.js"></script>
9+
<style>
10+
html, body {
11+
font-size:14px;
12+
min-width: 460px;
13+
min-height: 60px;
14+
}
15+
body {
16+
margin: 8px;
17+
}
18+
hr {
19+
width: 100%;
20+
}
21+
22+
button {
23+
height: 30px;
24+
width: 100px;
25+
outline: none;
26+
}
27+
a:link {
28+
text-decoration: none;
29+
}
30+
</style>
831
</head>
932
<body>
10-
Page Action
11-
<a href="http://www.google.com">Test - goto google</a>
12-
<button id="color_btn">CHANGE COLOR!</button>
33+
<p><strong>React Rewind</strong></p>
34+
<p>Open Chrome developer tools, React Rewind tab is on the right.</p>
35+
<a href="https://rewindjs.io">rewindjs.io</a>
36+
<a href="https://github.com/reactrewind/react-rewind">Github</a>
1337
<script src="page_action.js"></script>
1438
</body>
1539
</html>

src/browser/chrome/page_action.js

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
1-
document.addEventListener('DOMContentLoaded', () => {
2-
const btn = document.querySelector('#color_btn');
3-
btn.addEventListener('click', () => {
4-
chrome.tabs.query({ active: true, currentWindow: true }, function(tabs) {
5-
console.log(tabs);
6-
chrome.tabs.sendMessage(tabs[0].id, "change_color");
7-
});
8-
});
1+
document.addEventListener('DOMContentLoaded', function() {
2+
var links = document.getElementsByTagName('a');
3+
for (var i = 0; i < links.length; i++) {
4+
(function() {
5+
var ln = links[i];
6+
var location = ln.href;
7+
ln.onclick = function() {
8+
chrome.tabs.create({active: true, url: location});
9+
};
10+
})();
11+
}
912
});

0 commit comments

Comments
 (0)