Last active
June 7, 2018 06:08
-
-
Save jeanchernandez/88261e4904cb03fd60b36d542b0350ab to your computer and use it in GitHub Desktop.
Chrome Snippets
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
var keys = Array() | |
console.group("Instances"); | |
for (var id in savegame.instances) { | |
var instance = savegame.instances[id]; | |
console.log(id, instance); | |
for (var key in instance) { | |
if (keys.indexOf(key)==-1) { | |
keys.push(key); | |
} | |
} | |
} | |
console.groupEnd(); | |
console.group("Properties"); | |
console.log(keys); | |
console.groupEnd(); |
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
var products = Array(), | |
table = jQuery( '<table>' ); | |
table.attr( 'id', 'product_list' ); | |
table.append( | |
jQuery( '<thead>' ) | |
.append( | |
jQuery( '<tr>' ) | |
.append( | |
jQuery( '<td>' ).text('id'), | |
jQuery( '<td>' ).text('published'), | |
jQuery( '<td>' ).text('draft'), | |
jQuery( '<td>' ).text('image'), | |
jQuery( '<td>' ).text('name'), | |
jQuery( '<td>' ).text('slug'), | |
jQuery( '<td>' ).text('status'), | |
jQuery( '<td>' ).text('tags'), | |
jQuery( '<td>' ).text('product_cat'), | |
jQuery( '<td>' ).text('sku'), | |
jQuery( '<td>' ).text('regular_price'), | |
jQuery( '<td>' ).text('sale_price'), | |
jQuery( '<td>' ).text('weight'), | |
jQuery( '<td>' ).text('length'), | |
jQuery( '<td>' ).text('width'), | |
jQuery( '<td>' ).text('height'), | |
jQuery( '<td>' ).text('manage_stock'), | |
jQuery( '<td>' ).text('stock'), | |
jQuery( '<td>' ).text('featured'), | |
jQuery( '<td>' ).text('product_type'), | |
jQuery( '<td>' ).text('tax_status') | |
) | |
) | |
); | |
jQuery( '#the-list tr' ) | |
.each( function(row_index, row) { | |
var product = {}, | |
tr = jQuery( '<tr>' ); | |
row = jQuery( row ); | |
product.id = row.attr( 'id' ).replace( 'post-', '' ); | |
product.published = row.hasClass( 'status-published' ); | |
product.draft = row.hasClass( 'status-draft' ); | |
product.image = row.find( 'td.thumb img' ).attr( 'src' ).replace( '-150x150.', '.' ); | |
product.name = row.find( 'td.name > .hidden .post_title' ).text(); | |
product.slug = row.find( 'td.name > .hidden .post_name' ).text(); | |
product.status = row.find( 'td.name > .hidden ._status' ).text(); | |
product.tags = row.find( 'td.name > .hidden .tags_input' ).text(); | |
product.product_cat = row.find( 'td.product_cat' ).text(); | |
product.sku = row.find( 'td.name > .hidden .sku' ).text(); | |
product.regular_price = row.find( 'td.name > .hidden .regular_price' ).text(); | |
product.sale_price = row.find( 'td.name > .hidden .sale_price' ).text(); | |
product.weight = row.find( 'td.name > .hidden .weight' ).text(); | |
product.length = row.find( 'td.name > .hidden .length' ).text(); | |
product.width = row.find( 'td.name > .hidden .width' ).text(); | |
product.height = row.find( 'td.name > .hidden .height' ).text(); | |
product.manage_stock = row.find( 'td.name > .hidden .manage_stock' ).text(); | |
product.stock = row.find( 'td.name > .hidden .stock' ).text(); | |
product.featured = row.find( 'td.name > .hidden .featured' ).text(); | |
product.product_type = row.find( 'td.name > .hidden .product_type' ).text(); | |
product.tax_status = row.find( 'td.name > .hidden .tax_status' ).text(); | |
products.push( product ); | |
tr.append( jQuery( '<td>' ).text( product.id ) ); | |
tr.append( jQuery( '<td>' ).text( product.published ) ); | |
tr.append( jQuery( '<td>' ).text( product.draft ) ); | |
tr.append( jQuery( '<td>' ).text( product.image ) ); | |
tr.append( jQuery( '<td>' ).text( product.name ) ); | |
tr.append( jQuery( '<td>' ).text( product.slug ) ); | |
tr.append( jQuery( '<td>' ).text( product.status ) ); | |
tr.append( jQuery( '<td>' ).text( product.tags ) ); | |
tr.append( jQuery( '<td>' ).text( product.product_cat ) ); | |
tr.append( jQuery( '<td>' ).text( product.sku ) ); | |
tr.append( jQuery( '<td>' ).text( product.regular_price ) ); | |
tr.append( jQuery( '<td>' ).text( product.sale_price ) ); | |
tr.append( jQuery( '<td>' ).text( product.weight ) ); | |
tr.append( jQuery( '<td>' ).text( product.length ) ); | |
tr.append( jQuery( '<td>' ).text( product.width ) ); | |
tr.append( jQuery( '<td>' ).text( product.height ) ); | |
tr.append( jQuery( '<td>' ).text( product.manage_stock ) ); | |
tr.append( jQuery( '<td>' ).text( product.stock ) ); | |
tr.append( jQuery( '<td>' ).text( product.featured ) ); | |
tr.append( jQuery( '<td>' ).text( product.product_type ) ); | |
tr.append( jQuery( '<td>' ).text( product.tax_status ) ); | |
tr.appendTo( table ); | |
} ); | |
console.log( JSON.stringify(products) ); | |
if( jQuery( '#wpbody-content > #product_list' ).length > 0 ) { | |
jQuery( '#wpbody-content > #product_list' ).remove(); | |
} | |
table.appendTo( '#wpbody-content' ); |
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
// |
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
__loadScript("https://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js", function () { | |
//jQuery loaded | |
console.log('jquery loaded'); | |
}); |
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 __loadScript(url, callback) { | |
var script = document.createElement("script"); | |
script.type = "text/javascript"; | |
if (script.readyState) { //IE | |
script.onreadystatechange = function () { | |
if (script.readyState == "loaded" || script.readyState == "complete") { | |
script.onreadystatechange = null; | |
callback(); | |
} | |
}; | |
} else { //Others | |
script.onload = function () { | |
callback(); | |
}; | |
} | |
script.src = url; | |
document.getElementsByTagName("head")[0].appendChild(script); | |
} |
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 () { | |
function __loadScript(url, callback) { | |
var script = document.createElement("script"); | |
script.type = "text/javascript"; | |
if (script.readyState) { //IE | |
script.onreadystatechange = function () { | |
if (script.readyState == "loaded" || script.readyState == "complete") { | |
script.onreadystatechange = null; | |
callback(); | |
} | |
}; | |
} else { //Others | |
script.onload = function () { | |
callback(); | |
}; | |
} | |
script.src = url; | |
document.getElementsByTagName("head")[0].appendChild(script); | |
} | |
__loadScript("https://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js", function () { | |
$('body > img') | |
.css({ | |
'width': '100%', | |
'height': 'auto' | |
}); | |
$('<div>') | |
.css({ | |
'position': 'fixed', | |
'top': 0, | |
'bottom': 0, | |
'left': 0, | |
'right': 0, | |
'z-index': 9999, | |
'cursor': 'default' | |
}) | |
.appendTo('body'); | |
}); | |
})(); |
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
.post-image { | |
width: 100%; | |
height: 0; | |
padding-bottom: 50%; | |
position: relative; | |
overflow: hidden; | |
} | |
.post-image img { | |
position: absolute; | |
/* Position the image in the middle of its container. */ | |
top: -9999px; | |
right: -9999px; | |
bottom: -9999px; | |
left: -9999px; | |
margin: auto; | |
/* The following values determine the exact image behaviour. */ | |
/* You can simulate background-size: cover/contain/etc. | |
by changing between min/max/standard width/height values. | |
These values simulate background-size: cover | |
*/ | |
min-width: 100%; | |
min-height: 100%; | |
} |
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
$('item-selector').each(function(idx, item) { | |
item = $(item); | |
item.html( item.text().replace(/(?:\r\n|\r|\n)/g, '<br>') ); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment