Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
GoDaddy Store Export Bookmarklet
// Bookmarklet Code
javascript:(function()%7Bfunction%20callback()%7Bvoid%20function()%20%7Bfunction%20e(e%2C%20r%2C%20a)%20%7Bvar%20n%20%3D%20%22object%22%20!%3D%20typeof%20e%20%3F%20JSON.parse(e)%20%3A%20e%2C%20i%20%3D%20%22%22%3Bif%20(i%20%2B%3D%20r%20%2B%20%22%5Cr%5Cn%5Cn%22%2Ca)%20%7Bvar%20o%20%3D%20%22%22%3Bfor%20(var%20c%20in%20n%5B0%5D)o%20%2B%3D%20c%20%2B%20%22%2C%22%3Bo%20%3D%20o.slice(0%2C%20-1)%2Ci%20%2B%3D%20o%20%2B%20%22%5Cr%5Cn%22%7Dfor%20(var%20t%20%3D%200%3B%20t%20%3C%20n.length%3B%20t%2B%2B)%20%7Bvar%20o%20%3D%20%22%22%3Bfor%20(var%20c%20in%20n%5Bt%5D)o%20%2B%3D%20'%22'%20%2B%20n%5Bt%5D%5Bc%5D%20%2B%20'%22%2C'%3Bo.slice(0%2C%20o.length%20-%201)%2Ci%20%2B%3D%20o%20%2B%20%22%5Cr%5Cn%22%7Dif%20(%22%22%20%3D%3D%20i)return%20void%20alert(%22Invalid%20data%22)%3Bvar%20l%20%3D%20%22MyReport_%22%3Bl%20%2B%3D%20r.replace(%2F%20%2Fg%2C%20%22_%22)%3Bvar%20d%20%3D%20%22data%3Atext%2Fcsv%3Bcharset%3Dutf-8%2C%22%20%2B%20escape(i)%2C%20s%20%3D%20document.createElement(%22a%22)%3Bs.href%20%3D%20d%2Cs.style%20%3D%20%22visibility%3Ahidden%22%2Cs.download%20%3D%20l%20%2B%20%22.csv%22%2Cdocument.body.appendChild(s)%2Cs.click()%2Cdocument.body.removeChild(s)%7Dvar%20r%20%3D%20%5B%5D%2C%20a%20%3D%20window.location.origin%20%2B%20%22%2Fapi%2Fv1%2Fproducts%3Fper_page%3D100%22%3B%24.ajax(%7Burl%3A%20a%2Casync%3A%20!1%2Csuccess%3A%20function(e)%20%7Bconsole.log(e)%2C%24(e.products).each(function(a%2C%20n)%20%7Br.push(%7Bname%3A%20n.name.replace(%2F%22%2Fg%2C%20%22'%22)%2Cprice%3A%20n.price%2Csku%3A%20n.sku%2Cdescription%3A%20n.description.replace(%2F%22%2Fg%2C%20%22'%22)%2Cimage%3A%20n.master.images%5B0%5D.large_url%2Ccurrent_url%3A%20e.base_domain_url%20%2B%20n.relative_url%7D)%7D)%7D%7D)%2Cconsole.log(r)%2Ce(r%2C%20%22GoDaddy%22%2C%20!0)%7D()%7Dvar%20s%3Ddocument.createElement(%22script%22)%3Bs.src%3D%22https%3A%2F%2Fcode.jquery.com%2Fjquery-3.3.1.min.js%22%3Bif(s.addEventListener)%7Bs.addEventListener(%22load%22%2Ccallback%2Cfalse)%7Delse%20if(s.readyState)%7Bs.onreadystatechange%3Dcallback%7Ddocument.body.appendChild(s)%3B%7D)()
// Expanded Code
javascript: (function() {
function callback() {
void
function() {
function e(e, r, a) {
var n = "object" != typeof e ? JSON.parse(e) : e,
i = "";
if (i += r + "\r\n\n", a) {
var o = "";
for (var c in n[0]) o += c + ",";
o = o.slice(0, -1), i += o + "\r\n"
}
for (var t = 0; t < n.length; t++) {
var o = "";
for (var c in n[t]) o += '"' + n[t][c] + '",';
o.slice(0, o.length - 1), i += o + "\r\n"
}
if ("" == i) return void alert("Invalid data");
var l = "MyReport_";
l += r.replace(/ /g, "_");
var d = "data:text/csv;charset=utf-8," + escape(i),
s = document.createElement("a");
s.href = d, s.style = "visibility:hidden", s.download = l + ".csv", document.body.appendChild(s), s.click(), document.body.removeChild(s)
}
var r = [],
a = window.location.origin + "/api/v1/products?per_page=100";
$.ajax({
url: a,
async: !1,
success: function(e) {
console.log(e), $(e.products).each(function(a, n) {
r.push({
name: n.name.replace(/"/g, "'"),
price: n.price,
sku: n.sku,
description: n.description.replace(/"/g, "'"),
image: n.master.images[0].large_url,
current_url: e.base_domain_url + n.relative_url
})
})
}
}), console.log(r), e(r, "GoDaddy", !0)
}()
}
var s = document.createElement("script");
s.src = "https://code.jquery.com/jquery-3.3.1.min.js";
if (s.addEventListener) {
s.addEventListener("load", callback, false)
} else if (s.readyState) {
s.onreadystatechange = callback
}
document.body.appendChild(s);
})()
@michaelpanik

This comment has been minimized.

Copy link
Owner Author

@michaelpanik michaelpanik commented Sep 12, 2018

A Javascript bookmarklet that is an update of this one from Austin Hutchison.

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