我已经编写了一个自定义脚本,并添加了此脚本和一个自定义文本字段“ Calendly link”(链接到市场),在“付款”按钮上方创建了“可用性和预订”按钮。该脚本还负责将说明文本添加到列表中。代码的第一部分工作良好,并且按钮已自动添加,但是说明文本在“发布新列表页面”上不可见。
我试图快速看一下它,但不幸的是,我无法弄清楚为什么代码不起作用。它应该遍历页面上的所有标签,并在标有“ Calendly Link”的标签之后添加说明文本,但是由于某些原因在新列表页面中没有发生。有人可以帮我解决此问题吗?
这里是marketplace link。
发送整个脚本:
<link href="https://calendly.com/assets/external/widget.css" rel="stylesheet">
<script src="https://calendly.com/assets/external/widget.js" type="text/javascript"></script>
<script>
window.addEventListener('DOMContentLoaded', addCalendlyButtons);
function addCalendlyButtons() {
/* Hide calendly URL and add a booking button instead */
var rows = document.getElementsByClassName("col-12");
for (var i = 0; i < rows.length; i++) {
if (rows[i].innerText.match(/calendly link/i)) {
var calendlyURL = rows[i].innerText.match(/https:\/\/calendly\.com\/\S+/i)[0];
rows[i].innerHTML = "";
}
}
var order_button = document.getElementsByClassName('enabled-book-button')[0];
if (order_button != null && calendlyURL != null) {
order_button.insertAdjacentHTML( 'beforeBegin', '<button class="enabled-book-button" href="" onclick="Calendly.showPopupWidget(\'' + calendlyURL +'\');return false">Availability and reservation</button>' );
}
/* Add an instruction text to the listing form */
var infotext = 'If you want to allow hourly booking, set up an event for free at <a href="http://calendly.com" target="_blank">Calendly.com </a> and put here the link to that calendly event.'
var labels = document.getElementsByTagName('LABEL');
for (var i = 0; i < labels.length; i++) {
if (labels[i].textContent == 'Calendly link') {
labels[i].insertAdjacentHTML( 'afterend', '<div class="info-text-container"><div class="info-text-icon"><i class="ss-info"></i></div><div class="info-text-content"><p>' + infotext + '</p></div></div>' );
}
}
}
</script>