Skip to content

Instantly share code, notes, and snippets.

Avatar

Simeon Vincent dotproto

View GitHub Profile
@dotproto
dotproto / devtools.html
Created Sep 8, 2021
DevTools network request monitor. Minimal demo to show how one could use `chrome.devtools.network.onRequestFinished` to monitor request traffic on a given page.
View devtools.html
<!DOCTYPE html>
<script src="devtools.js"></script>
@dotproto
dotproto / index.html
Created Sep 7, 2021
Test: Spawn a WebWorker inside a service worker. This test was created to verify whether or not standard web workers can be instantiated from within a service worker.
View index.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width">
<title>Web Workers basic example</title>
</head>
<body>
<script src="main.js"></script>
@dotproto
dotproto / background.js
Last active Aug 24, 2021
Inject video on page that has a CSP restrict that would normally prevent the video from being injected. To see this demo in action, load the extension unpacked and trigger the extension's action on the desired page.
View background.js
// Copyright 2021 Google LLC.
// SPDX-License-Identifier: Apache-2.0
let videos = [
{
url: 'https://interactive-examples.mdn.mozilla.net/media/cc0-videos/flower.mp4',
type: 'video/mp4',
}, {
url: 'https://interactive-examples.mdn.mozilla.net/media/cc0-videos/flower.webm',
type: 'video/webm',
@dotproto
dotproto / index.html
Created Aug 13, 2021
Include 3rd party images/images in a Manifest V3 extension page
View index.html
<!--
Copyright 2021 Google LLC.
SPDX-License-Identifier: Apache-2.0
-->
<video width="320" height="240" controls
preload="none" playsinline="" aria-label="Stephen Colbert Popcorn Munching GIF"
disablepictureinpicture="" poster="https://pbs.twimg.com/tweet_video_thumb/E8o7fA9VoAojxVl.jpg"
src="https://video.twimg.com/tweet_video/E8o7fA9VoAojxVl.mp4" type="video/mp4"></video>
@dotproto
dotproto / background.js
Created Jul 23, 2021
Manifest V3 module service worker demo
View background.js
// Copyright 2021 Google LLC
//
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file or at
// https://developers.google.com/open-source/licenses/bsd
// Use importScripts to load other JS files
import { demo } from './lib.js';
console.log(demo.greeting);
@dotproto
dotproto / background.js
Created Jul 23, 2021
Manifest V3 importScripts try/catch demo
View background.js
// Copyright 2021 Google LLC
//
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file or at
// https://developers.google.com/open-source/licenses/bsd
// Use importScripts to load other JS files
importScripts('./lib.js');
console.log(self.demo.greeting);
@dotproto
dotproto / background.js
Created Jan 11, 2021
Basic example of requesting optional broad host permissions
View background.js
// Copyright 2019 Google LLC.
// SPDX-License-Identifier: Apache-2.0
chrome.runtime.onInstalled.addListener(({reason}) => {
console.log(reason);
console.log(chrome.runtime.OnInstalledReason.UPDATE);
if (reason === chrome.runtime.OnInstalledReason.INSTALL ||
reason === chrome.runtime.OnInstalledReason.UPDATE) {
chrome.tabs.create({url: 'popup.html'});
@dotproto
dotproto / LICENSE
Last active Jul 16, 2020
MV3 webRequest demo. To view the console, you may need to manually open devtools for the service worker. On Chrome, visit chrome://serviceworker-internals and search for the service worker registered to `chrome-extension://<extension-id>/` where extension-id is the ID of your extension.
View LICENSE
Copyright 2020 Google LLC
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
https://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
@dotproto
dotproto / background.js
Created Feb 26, 2020
Simple Chrome Extension messaging demo modeled after the TCP/IP handshake (SYN, SYN-ACK, ACK)
View background.js
// Copyright 2020 Google LLC.
// SPDX-License-Identifier: Apache-2.0
// Start synchronizaiton on browser action click
chrome.browserAction.onClicked.addListener(function(tab) {
console.log('Handshake initiated: BG sending SYN');
chrome.tabs.sendMessage(tab.id, { type: 'bg-syn' });
});
chrome.runtime.onMessage.addListener(function(message, sender, sendResponse) {
@dotproto
dotproto / LICENSE
Created Nov 15, 2019
Minimal working Manifest V3 extension.
View LICENSE
Copyright 2019 Google LLC
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
https://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,