Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@mastef
Last active June 10, 2022 13:03
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save mastef/9a84666759796ae9df65edde69130465 to your computer and use it in GitHub Desktop.
Save mastef/9a84666759796ae9df65edde69130465 to your computer and use it in GitHub Desktop.
Extract Pricing template from Google Play Console to .csv format
// Go to "All Applications" / "Settings" / "Pricing templates" and select the template you want to export
javascript: (function(e, s) {
e.src = s;
e.onload = function() {
jQuery.noConflict();
console.log('jQuery injected');
$ = jQuery;
extractData();
};
document.head.appendChild(e);
})(document.createElement('script'), '//code.jquery.com/jquery-latest.min.js')
function extractData() {
var tbl = $($('section table tbody')[0]).find('tr').get().map(function(row) {
return $(row).find('td').get().map(function(cell) {
var a = $(cell).find('input');
if(a.length > 0) {
if(!!a[0].value) {
if(a[0].value != "on") {
return [a[0].value.replace(",",""), $(cell).find('label span').text()];
}
}
}
if($(cell).text().indexOf("%") > -1) {
return $(cell).text().split(" ")[0];
}
return $(cell).text();
});
});
function toCSV(input) {
var output = "Country,Price,Currency,Tax\n";
input.forEach(function(a,b){
a.shift();
a.splice(1,1);
output += a.toString() + '\n';
});
return output;
}
var templateName = $($('section div div')[1]).text().trim();
console.log("Template:",templateName);
var templateID = templateName.split("ID :")[1].trim();
var templateOutput = toCSV(tbl);
console.log(templateOutput);
$('#dlbutton').remove();
$("body").append($("<a id='dlbutton'/>"));
$('#dlbutton').attr("download", templateID + ".csv");
$('#dlbutton').attr("href", "data:text/csv;charset=utf8," + encodeURIComponent(templateOutput));
$('#dlbutton')[0].click();
}
@RegisAG
Copy link

RegisAG commented Apr 6, 2018

Hi. How to use this ? Thanks a lot.

@romaroma
Copy link

Hi. How to use this ? Thanks a lot.

Open JavaScript Console in Chrome, paste this code and get all the prices in a pure csv file.

@saipsa
Copy link

saipsa commented May 7, 2019

How to import it later?

@jiieun
Copy link

jiieun commented Jun 14, 2019

Thanks for sharing!

@vik17ag
Copy link

vik17ag commented Feb 25, 2021

Not working now. Shows this error
```VM2068:9 Refused to load the script 'https://code.jquery.com/jquery-latest.min.js' because it violates the following Content Security Policy directive: "script-src 'report-sample' 'nonce-sXivvcR9QVVw8259pNoTxA' 'unsafe-inline' 'unsafe-eval'". Note that 'script-src-elem' was not explicitly set, so 'script-src' is used as a fallback.`

@mastef
Copy link
Author

mastef commented Feb 25, 2021

@vik17ag you can try with copying the contents of https://code.jquery.com/jquery-latest.min.js and pasting them in the console. If that works then paste everything after line 14 in this gist, and finally run extractData()

But I'm not sure this will still work - I made this a long time ago and the google interface must have changed since then.

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