Skip to content

Instantly share code, notes, and snippets.

@mergado-com
Last active September 16, 2025 09:20
Show Gist options
  • Save mergado-com/75cc3ac76a9af2a2a024fe790adc00fe to your computer and use it in GitHub Desktop.
Save mergado-com/75cc3ac76a9af2a2a024fe790adc00fe to your computer and use it in GitHub Desktop.
Shoptet recenze produktů
(function() {
function parseCzechDatetime(datetimeStr) {
const parts = datetimeStr.trim().split(' ');
const dateParts = parts[0].split('.');
if (dateParts.length === 3) {
const day = dateParts[0].padStart(2, '0');
const month = dateParts[1].padStart(2, '0');
const year = dateParts[2];
return `${year}-${month}-${day}`;
}
return '';
}
const rows = document.querySelectorAll('tbody tr');
const csvRows = [];
// Judge.me CSV hlavička (pro Shopify import)
csvRows.push([
"product_handle",
"review_title",
"body",
"reviewer_name",
"reviewer_email",
"rating",
"review_date",
"reply",
"reply_date",
"featured",
"verified",
"hidden"
].join(','));
rows.forEach((row) => {
const stars = row.querySelectorAll('td[data-testid=\"starRating\"] .star-on').length;
const productNameCell = row.querySelector('td[data-testid=\"textProductName\"]');
const commentCell = row.querySelector('td[data-testid=\"textDescription\"]');
const authorCell = row.querySelector('td[data-testid=\"authorName\"]');
const dateCell = row.querySelector('td[data-testid=\"textDate\"]');
const replyCell = row.querySelector('td[data-testid=\"textReaction\"]');
const visibilityIcon = row.querySelector('td:last-child a[data-testid=\"universalDisabledClass\"]');
if (!productNameCell || !commentCell || !authorCell || !dateCell || !visibilityIcon || stars === 0) return;
const productName = productNameCell.textContent.trim().replace(/\s+/g, ' ').replace(/"/g, '\'');
const comment = commentCell.textContent.trim().replace(/\s+/g, ' ').replace(/"/g, '\'');
const rawAuthor = Array.from(authorCell.childNodes)
.filter(node => node.nodeType === Node.TEXT_NODE)
.map(node => node.textContent.trim())
.join(' ')
.trim();
const author = rawAuthor === '' ? '' : rawAuthor;
const reviewerEmail = "";
const reply = replyCell?.textContent.trim().replace(/\s+/g, ' ').replace(/"/g, '\'') || "";
const replyDate = reply ? new Date().toISOString().replace('T', ' ').split('.')[0] + ' UTC' : "";
const dateRaw = dateCell.textContent.trim();
const parsedDate = parseCzechDatetime(dateRaw);
const isHidden = visibilityIcon.classList.contains('disabled') ? "TRUE" : "FALSE";
const reviewTitle = comment.split(' ').slice(0, 5).join(' ');
const rowArray = [
productName,
reviewTitle,
comment,
author,
reviewerEmail,
stars,
parsedDate,
reply,
replyDate,
"FALSE",
"TRUE",
isHidden
];
csvRows.push(rowArray.map(f => `"${f}"`).join(','));
});
const csvContent = "data:text/csv;charset=utf-8," + csvRows.join("\n");
const encodedUri = encodeURI(csvContent);
const link = document.createElement("a");
link.setAttribute("href", encodedUri);
link.setAttribute("download", "judgeme-import.csv");
document.body.appendChild(link);
link.click();
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment