Last active
February 28, 2025 06:43
-
-
Save mastef/9a84666759796ae9df65edde69130465 to your computer and use it in GitHub Desktop.
Extract Pricing template from Google Play Console to .csv format
This file contains hidden or 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
// 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(); | |
} |
Thanks for sharing!
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.`
@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
How to import it later?