This file contains 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
// jquerify.js | |
// https://github.com/bgrins/devtools-snippets | |
// Add jQuery to any page that does not have it already. | |
(function () { | |
if ( !window.jQuery ) { | |
var s = document.createElement('script'); | |
s.setAttribute('src', '//ajax.googleapis.com/ajax/libs/jquery/2.0.3/jquery.min.js'); | |
document.body.appendChild(s); |
This file contains 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
// log.js | |
// https://github.com/bgrins/devtools-snippets | |
// Adds a `log` function to window object. | |
// http://www.briangrinstead.com/blog/console-log-helper-function | |
(function() { | |
window.log = Function.prototype.bind.call(console.log, console); | |
})(); |
This file contains 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
// showheaders.js | |
// https://github.com/bgrins/devtools-snippets | |
// Print out response headers for current URL. | |
(function() { | |
var request=new XMLHttpRequest(); | |
request.open('HEAD',window.location,false); | |
request.send(null); |
This file contains 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
// dataurl.js | |
// https://github.com/bgrins/devtools-snippets | |
// Print out data URLs for all images / canvases on the page. | |
(function() { | |
console.group("Data URLs"); | |
[].forEach.call(document.querySelectorAll("img"), function(i) { | |
var c = document.createElement("canvas"); |
This file contains 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
// allcolors.js | |
// https://github.com/bgrins/devtools-snippets | |
// Print out CSS colors used in elements on the page. | |
(function () { | |
var allColors = {}; | |
var props = ["background-color", "color", "border-top-color", "border-right-color", "border-bottom-color", "border-left-color"]; | |
var skipColors = { "rgb(0, 0, 0)": 1, "rgba(0, 0, 0, 0)": 1, "rgb(255, 255, 255)": 1 }; | |
[].forEach.call(document.querySelectorAll("*"), function (node) { |
This file contains 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
// performance.js | |
// https://github.com/bgrins/devtools-snippets | |
// Print out window.performance information. | |
// https://developer.mozilla.org/en-US/docs/Navigation_timing | |
(function () { | |
var t = window.performance.timing; | |
var timings = []; |
This file contains 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
// querystringvalues.js | |
// https://github.com/bgrins/devtools-snippets | |
// Print out key/value pairs from querystring. | |
(function() { | |
var url = location; | |
var querystring = location.search.slice(1); | |
var tab = querystring.split("&").map(function(qs) { | |
return { "Key": qs.split("=")[0], "Value": qs.split("=")[1], "Pretty Value": decodeURIComponent(qs.split("=")[1]).replace(/\+/g," ") } |
This file contains 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
// wrapelement.js | |
// https://github.com/bgrins/devtools-snippets | |
// Wrap a given element in a given type of element | |
// wrapElement('.foo', 'h1'); | |
// wrapElement(document.querySelector('#bar'), 'div'); | |
// | |
// LICENSE: [MIT](http://gkatsev.mit-license.org) | |
(function() { | |
window.wrapElement = function(el, whatToWrapIn) { |
This file contains 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
// formcontrols.js | |
// https://github.com/bgrins/devtools-snippets | |
// Print out forms and their controls | |
(function() { | |
var forms = document.querySelectorAll("form"); | |
for (var i = 0, len = forms.length; i < len; i++) { | |
var tab = [ ]; |
This file contains 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
function WatchedProp (obj, prop){ | |
obj["_"+prop] = obj[prop]; | |
// overwrite with accessor | |
Object.defineProperty(obj, prop, { | |
get: function () { | |
return obj["_"+prop]; | |
}, |
OlderNewer