-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
AP
authored and
AP
committed
Apr 16, 2020
0 parents
commit 72b3811
Showing
10 changed files
with
81 additions
and
0 deletions.
There are no files selected for viewing
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
|
||
chrome.runtime.onInstalled.addListener(function() { | ||
chrome.storage.sync.set({color: '#3aa757'}, function() { | ||
console.log("The color is green."); | ||
}); | ||
chrome.declarativeContent.onPageChanged.removeRules(undefined, function() { | ||
chrome.declarativeContent.onPageChanged.addRules([{ | ||
conditions: [new chrome.declarativeContent.PageStateMatcher({ | ||
pageUrl: {hostEquals: 'developer.chrome.com'}, | ||
}) | ||
], | ||
actions: [new chrome.declarativeContent.ShowPageAction()] | ||
}]); | ||
}); | ||
|
||
console.log(document.body) | ||
// document.querySelector('#button').addEventListener('click', function() { | ||
// console.log(this); | ||
// }) | ||
}); |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
{ | ||
"name": "Getting Started Example", | ||
"version": "1.0", | ||
"description": "Build an Extension!", | ||
"permissions": ["activeTab", "declarativeContent", "storage"], | ||
"background": { | ||
"scripts": ["popup.js", "background.js"], | ||
"persistent": false | ||
}, | ||
"page_action": { | ||
"default_popup": "popup.html", | ||
"default_icon": { | ||
"16": "images/get_started16.png", | ||
"32": "images/get_started32.png", | ||
"48": "images/get_started48.png", | ||
"128": "images/get_started128.png" | ||
} | ||
}, | ||
"icons": { | ||
"16": "images/get_started16.png", | ||
"32": "images/get_started32.png", | ||
"48": "images/get_started48.png", | ||
"128": "images/get_started128.png" | ||
}, | ||
"manifest_version": 2 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<link rel="stylesheet" href="style.css"> | ||
<script src="background.js"></script> | ||
<script src="popup.js"></script> | ||
</head> | ||
<body> | ||
<p>button</p> | ||
<button id="changeColor"></button> | ||
|
||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
let changeColor = document.getElementById('changeColor'); | ||
console.log(document.body); | ||
|
||
|
||
changeColor.onclick = function(element) { | ||
console.log(this) | ||
let color = element.target.value; | ||
chrome.tabs.query({active: true, currentWindow: true}, function(tabs) { | ||
chrome.tabs.executeScript( | ||
tabs[0].id, | ||
{code: 'document.body.style.backgroundColor = "' + color + '";'}); | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
button { | ||
height: 30px; | ||
width: 30px; | ||
outline: none; | ||
} | ||
|
||
body { | ||
color: red; | ||
} |