This file contains hidden or 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
| <style> | |
| /* https://github.com/lonekorean/gist-syntax-themes */ | |
| @import url('https://cdn.rawgit.com/lonekorean/gist-syntax-themes/d49b91b3/stylesheets/idle-fingers.css'); | |
| @import url('https://fonts.googleapis.com/css?family=Open+Sans'); | |
| body { | |
| font: 16px 'Open Sans', sans-serif; | |
| } | |
| body .gist .gist-file { | |
| border-color: #555 #555 #444 |
This file contains hidden or 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
| const [array, setArray] = useState([]); | |
| // Good | |
| const addValue = (value) => | |
| setArray(prevArray => [...prevArray, value]) | |
| // Bad, this is closure | |
| const addValue = (value) => | |
| setArray([...array, value]) |
This file contains hidden or 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
| { | |
| "name": "Great Extension", | |
| "version": "1.0", | |
| "description": "Build an Extension with Angular", | |
| "manifest_version": 2 | |
| } |
This file contains hidden or 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
| chrome.runtime.onInstalled.addListener(() => { | |
| chrome.storage.sync.set({ color: '#3aa757' }); | |
| chrome.webNavigation.onCompleted.addListener(() => { | |
| chrome.tabs.query({ active: true, currentWindow: true }, ([{ id }]) => { | |
| if (id) { | |
| chrome.pageAction.show(id); | |
| } | |
| }); | |
| }, { url: [{ urlMatches: 'google.com' }] }); |
This file contains hidden or 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
| ngOnInit(): void { | |
| chrome.storage.sync.get('color', ({ color }) => { | |
| this.color = color; | |
| }); | |
| } |
This file contains hidden or 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
| <span [style.color]="color" | |
| [cpToggle]="true" | |
| [cpDialogDisplay]="'inline'" | |
| [cpPositionRelativeToArrow]="true" | |
| [(colorPicker)]="color" | |
| [cpOKButtonText]="'Apply'" | |
| [cpOKButton]="true" | |
| (colorPickerChange)="updateColor($event)" | |
| (colorPickerSelect)="colorize()"> | |
| </span> |
This file contains hidden or 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
| { | |
| "name": "Great Extension", | |
| "version": "1.0", | |
| "description": "Build an Extension with Angular", | |
| "manifest_version": 2, | |
| "permissions": [ | |
| "activeTab", | |
| "webNavigation", | |
| "storage" | |
| ], |
This file contains hidden or 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
| <span [style.color]="color" | |
| [cpToggle]="true" | |
| [cpDialogDisplay]="'inline'" | |
| [cpPositionRelativeToArrow]="true" | |
| [(colorPicker)]="color" | |
| [cpOKButtonText]="'Apply'" | |
| [cpOKButton]="true" | |
| (colorPickerSelect)="colorize()"> | |
| </span> |
This file contains hidden or 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
| export class AppComponent { | |
| color = '#ffffff'; | |
| public colorize() { | |
| chrome.tabs.query({ active: true, currentWindow: true }, tabs => { | |
| chrome.tabs.executeScript( | |
| tabs[0].id!, | |
| { code: `document.body.style.backgroundColor = '${ this.color }';` } | |
| ); | |
| }); |
This file contains hidden or 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
| body { | |
| margin: 0; | |
| } |