Skip to content

Instantly share code, notes, and snippets.

@curtisj44
Last active March 15, 2022 09:04
Show Gist options
  • Save curtisj44/10052727 to your computer and use it in GitHub Desktop.
Save curtisj44/10052727 to your computer and use it in GitHub Desktop.
Pesticide CSS bookmarklet
var link,
id = 'Pesticide';
pesticide = document.getElementById(id);
if (pesticide === null) {
console.log(id + ' added');
link = document.createElement('link');
link.id = id;
link.rel = 'stylesheet';
// Using jsdelivr link since raw CSS from GitHub doesn't seem to work
// (https://raw.githubusercontent.com/mrmrs/pesticide/master/css/pesticide.min.css)
link.href = 'https://cdn.jsdelivr.net/npm/pesticide@1.3.1/css/pesticide.min.css';
document.body.appendChild(link);
} else {
console.log(id + ' removed');
document.body.removeChild(pesticide);
}
@curtisj44
Copy link
Author

curtisj44 commented Apr 7, 2014

A bookmarklet to add the debugging styles from Pesticide.io. Linking bookmarklets intentionally doesn't work on GitHub, so here are some quick instructions:

  1. Copy the code below:
javascript:(function(){var%20link,id='Pesticide';pesticide=document.getElementById(id);if(pesticide===null){console.log(id+'%20added');link=document.createElement('link');link.id=id;link.rel='stylesheet';link.href='http://pesticide.io/css/layout_debug.min.css';document.body.appendChild(link);}else{console.log(id+'%20removed');document.body.removeChild(pesticide);}})();
  1. Create a new bookmark.
  2. Set the bookmarklet name and paste the above as the URL.

@maxfenton
Copy link

The JS this includes has been removed. Maybe you could pull from a raw github file instead.

@curtisj44
Copy link
Author

curtisj44 commented Jan 5, 2021

Oh yeah. It looks like that pesticide.io domain is not a thing anymore. I've updated the gist.

This is the updated bookmarklet:

javascript:(function(){var link,id='Pesticide';pesticide=document.getElementById(id);if(pesticide===null){console.log(id+' added');link=document.createElement('link');link.id=id;link.rel='stylesheet';link.href='https://cdn.jsdelivr.net/npm/pesticide@1.3.1/css/pesticide.min.css';document.body.appendChild(link);}else{console.log(id+' removed');document.body.removeChild(pesticide);}})();

@maxfenton
Copy link

Amazing. I didn't think to look on a CDN.

@philsmithies
Copy link

Any idea how to get this to work with safari? It's working great in Brave but I already have a chrome extension for that.

@maxfenton
Copy link

maxfenton commented Mar 14, 2022

@philsmithies In theory it’s as easy as making any bookmarklet:

  1. make a new bookmark.
  2. edit the url of that bookmark to be the whole javascript snippet above

But these days with any bookmarketl (in Safari or otherwise) you're likely to hit one of these:

Refused to load https://cdn.jsdelivr.net/npm/pesticide@1.3.1/css/pesticide.min.css because it does not appear in the style-src directive of the Content Security Policy.

@philsmithies
Copy link

philsmithies commented Mar 15, 2022 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment