Skip to content

Instantly share code, notes, and snippets.

View alejandrocoding's full-sized avatar
🏠
Working from home

Alejandro Lora alejandrocoding

🏠
Working from home
View GitHub Profile
@alejandrocoding
alejandrocoding / manifest.json
Created June 12, 2020 16:34
Minimal version of manifest.json for Chrome Extensions Apps
{
"name": "My Extension",
"version": "1.0.0",
"description": "Description here",
"manifest_version": 2,
"permissions": ["webNavigation", "tabs"]
}
@alejandrocoding
alejandrocoding / angular.json5
Last active June 12, 2020 17:04
Angular json file with the manifest.json added in the assets array of the build-options configuration
"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
...
"projects": {
"chrome-extension-template": {
...
"architect": {
"build": {
"builder": "@angular-devkit/build-angular:browser",
"options": {
...
@alejandrocoding
alejandrocoding / background.ts
Created June 12, 2020 17:59
Chrome extension background.ts sample to filter out by github.com domain
chrome.runtime.onInstalled.addListener(() => {
chrome.webNavigation.onCompleted.addListener(() => {
chrome.tabs.query({ active: true, currentWindow: true }, ([{ id }]) => {
chrome.pageAction.show(id);
});
}, { url: [{ urlMatches: 'https://github.com/' }] });
});
@alejandrocoding
alejandrocoding / manifest.json
Last active June 12, 2020 18:15
Manifest for Chrome Extension adding background file in Angular app
{
"name": "My Extension",
"version": "1.0.0",
"description": "Description here",
"manifest_version": 2,
"permissions": ["webNavigation", "tabs"],
"page_action": {
"default_popup": "index.html"
},
"background": {
@alejandrocoding
alejandrocoding / angular.json5
Created June 12, 2020 18:36
Angular json file bundle with custom webpack
{
"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
...
"projects": {
"chrome-extension-template": {
...
"architect": {
"build": {
"builder": "@angular-builders/custom-webpack:browser",
"options": {
@alejandrocoding
alejandrocoding / tsconfig.app.json
Created June 12, 2020 18:55
Tsconfig includes background and contentScript into the TS compilation
{
"extends": "./tsconfig.json",
"compilerOptions": {
"outDir": "./out-tsc/app",
"types": ["chrome"]
},
"files": [
"src/main.ts",
"src/polyfills.ts",
"src/background.ts",
@alejandrocoding
alejandrocoding / contentScript.ts
Created June 12, 2020 23:16
Chrome Extension contentScript.ts log
console.log('Hola desde ContentScript.ts!!');
@alejandrocoding
alejandrocoding / manifest.json
Created June 12, 2020 23:24
Chrome Extension with background and contentScript entries
{
"name": "My Extension",
"version": "1.0.0",
"description": "Description here",
"manifest_version": 2,
"permissions": ["webNavigation", "tabs"],
"page_action": {
"default_popup": "index.html"
},
"background": {
@alejandrocoding
alejandrocoding / custom-webpack-dev.config.js
Created June 12, 2020 23:35
Chrome Extension Live reload for background and contentScript in dev
const ExtensionReloader = require('webpack-extension-reloader')
const config = require('./custom-webpack.config');
module.exports = {...config,
mode: 'development',
plugins: [new ExtensionReloader({
reloadPage: true,
entries: {
background: 'background',
contentScript: 'contentScript'
@alejandrocoding
alejandrocoding / angular.json5
Created June 12, 2020 23:40
Chrome Extension angular.json with live reload only in dev mode
{
"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
...
"projects": {
"chrome-extension-template": {
...
"architect": {
"build": {
"builder": "@angular-builders/custom-webpack:browser",
"options": {