复制竞品的评论,导出为xls格式。仅适用于Loox ‑ Product Reviews App插件。
JavaScript
const data = ((product, startDate) => {
function getRandomDateString(startDateStr) {
const start = new Date(startDateStr);
const end = new Date();
const randomTime = start.getTime() + Math.random() * (end.getTime() - start.getTime());
const randomDate = new Date(randomTime);
const yyyy = randomDate.getFullYear();
const mm = String(randomDate.getMonth() + 1).padStart(2, '0');
const dd = String(randomDate.getDate()).padStart(2, '0');
return `${yyyy}-${mm}-${dd}`;
}
return [
...['product_handle,rating,author,email,body,created_at,photo_url,verified_purchase'],
...[...document.querySelectorAll('#grid .grid-item-wrap')].map(el => {
const author = el.querySelector('.block.title').firstChild.textContent.trim();
const email = author.replace(/[.\s]/g, '').toLowerCase() + '@gmail.com';
const body = el.querySelector('.main-text').firstChild.textContent.trim();
const time = getRandomDateString(startDate) + ' 00:00:00 UTC';
const photo_url = el.classList.contains('has-img') ? 'https:' + el.querySelector('.item-img.box img').getAttribute('src') : '';
return `${product},5,"${author}","${email}","${body}",${time},"${photo_url}",TRUE`
})
];
})('pynior-pro', '2025-01-01');
const csvContent = data.join('\n');
const blob = new Blob([csvContent], { type: 'text/csv;charset=utf-8;' });
const url = URL.createObjectURL(blob);
const a = document.createElement('a');
a.href = url;
a.download = 'data.csv';
document.body.appendChild(a);
a.click();
document.body.removeChild(a);
URL.revokeObjectURL(url);
使用方式:在竞品的评论区,右键点击检查(Inspect),然后在开发者工具控制台(console)粘贴以下代码,即可自动下载csv。
最后到自己的shopify后台,在Loox ‑ Product Reviews App的导入功能中,导入这个csv文件。