-
-
Save mergado-com/e3d8bbb59c9fbf1241cd6b7592d95dc7 to your computer and use it in GitHub Desktop.
Shoptet recenze obchodu
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
| (function() { | |
| function parseCzechDatetime(datetimeStr) { | |
| const parts = datetimeStr.trim().split(' '); | |
| const dateParts = parts[0].split('.'); | |
| const timePart = parts[1] || "00:00"; | |
| 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 | |
| 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 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 (!commentCell || !authorCell || !dateCell || !visibilityIcon || stars === 0) return; | |
| 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'); | |
| const hidden = isHidden ? "TRUE" : "FALSE"; | |
| const productHandle = "recenze-obchodu"; | |
| const reviewTitle = comment.split(' ').slice(0, 5).join(' '); | |
| const rowArray = [ | |
| productHandle, | |
| reviewTitle, | |
| comment, | |
| author, | |
| reviewerEmail, | |
| stars, | |
| parsedDate, | |
| reply, | |
| replyDate, | |
| "FALSE", | |
| "TRUE", | |
| hidden | |
| ]; | |
| 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