Skip to content

Instantly share code, notes, and snippets.

@keighty
keighty / devtools.html
Created October 26, 2016 03:43
Basic project outline for creating a dev-tools extension
<!DOCTYPE html>
<html>
<body>
<script src="devtools.js"></script>
</body>
</html>
console.log("hello from devtools.js");
chrome.devtools.panels.create("ColdFire","coldfusion10.png","panel.html", function(panel) {
panel.onShown.addListener(function(win) {
console.log('i think this is the right onshow');
var status = win.document.querySelector("#status");
status.innerHTML = "Fixing to make magic.";
});
chrome.devtools.network.onRequestFinished.addListener(
@ervinne13
ervinne13 / add-view-in-new-tab
Created May 17, 2024 00:02
Adds a "View in New Tab" button in nahida.live/mods so that you don't need to register and convert base64s to get to the download page.
const elements = document.querySelectorAll(`.card`);
elements.forEach(element => {
const button = document.createElement('button');
button.innerText = 'View in New Tab';
button.className = 'custom-button';
button.onclick = function () {
const imgWithUUID = element.querySelector('figure > img');
const imgUrl = imgWithUUID.src
console.log("hello from devtools");
chrome.devtools.panels.create("ColdFire",
"coldfusion10.png",
"panel.html",
function(panel) { console.log("hello from callback"); });
@sivagao
sivagao / jQueryAudit.js
Last active May 17, 2024 01:34
jQuery Audit Chrme Plugin , show how to create a sidebar panel & jQuery inner data.
/* jslint browser: true */
/* global chrome, $0 */
var getPanelContents = function () {
if (!$0) return;
// In case we're in an <iframe>
var document = $0.ownerDocument;
var window = document.defaultView;
@Avi98
Avi98 / Search
Created September 3, 2018 19:44
Search
chrome.devtools.panels.create('React', '', 'panel.html', function(panel) {
var reactPanel = null;
panel.onShown.addListener(function(window) {
// when the user switches to the panel, check for an elements tab
// selection
window.panel.getNewSelection();
reactPanel = window.panel;
reactPanel.resumeTransfer();
});
panel.onHidden.addListener(function() {
/*
* bug 814641 - [toolbox] Panels appear behind the devtools window after undocking
* STR:
* Run this browser scratchpad.
* click on "open". You see an arrow panel.
* Move your mouse over it, see the spinning cursor.
* click swap to swap the frames.
* click on "open". You do _NOT_ see the panel.
* Move your mouse where it should have appeared. See the spinning cursor.
*/
@bkimmelSQSP
bkimmelSQSP / snippet.js
Created September 16, 2021 05:20
Transfers to LocalCache from a Common (iframe) cache
const urlToStoreInCommonCache = `https://assets.squarespace.com/universal/scripts-compressed/config-vendors-b6b69075bd69ac75a13bd-min.en-US.js`;
caches.match(urlToStoreInCommonCache).then((response)=>{
if(!response){
window.addEventListener('message', (msg)=>{
if(msg.data === 'common cache ready'){
console.log('COMMON CACHE READY');
const cachePort = msg.ports[0];
cachePort.onmessage = (cachedArrayBuffer)=>{
const resp = new Response(cachedArrayBuffer);
caches.open('zany-cache').then((cache)=>{
@bkimmelSQSP
bkimmelSQSP / renderJSON.js
Last active May 17, 2024 01:33
Final Answer
const converted = Symbol('object was alrady converted');
function renderJSON(configObject) {
const handler = {
get(target, prop, receiver) {
Reflect.defineProperty(receiver, converted, {value: true, enumerable: false, writable: false, configurable: false});
if (prop === "toJSON") {
for (const ownKey of Reflect.ownKeys(target)) {
const val = Reflect.get(target, ownKey);
const invariantCheck = Reflect.getOwnPropertyDescriptor(target, ownKey);
if(invariantCheck.writable === false || invariantCheck.configurable === false){