admin管理员组文章数量:1417974
Need to programmatically check comment text before posting, to stop spam. Have developed J-script to search a list of URLs used by spammers and then reject the comment. Need to understand (1) how to inject the J-script into the Squarespace HTML and (2) how to invoke the Squarespace comment post function once the comment is approved. A typical article created for a Squarespace webpage contains the following HTML:
<!--NEW COMMENT TOP-->
<div class="new-comment-area top-level-comment-area edit-mode">
<!-- <span class="squarespace-comment-login"></span> <div class="new-comment-title">Add Comment</div>-->
<div class="input">
<form action="; method="post" class="comment-form">
<textarea class="comment-input" name="comment" data-defaulttext="Leave a comment here." data-edited="false"></textarea>
</form>
</div>
<div class="comment-btn-wrapper">
<span class="btn-text preview-comment top-level-preview-btn">Preview</span>
<!--toggle class on .new-comment-area to hide/show the appropriate button below
<span class="btn-text edit-comment">Edit</span>-->
<span class="comment-btn sqs-system-button sqs-editable-button-font sqs-editable-button-shape sqs-button-element--primary">
Post Comment…
</span>
</div>
</div>
I have developed the following substitute "new-comment-area" class, that checks the comment text and decides whether to approve or deny the comment:
<!DOCTYPE html>
<html>
<div class="new-comment-area top-level-comment-area edit-mode">
<div class="input">
<form action="; method="post" class="comment-form">
<textarea class="comment-input" id="comment" name="comment" data-defaulttext="Leave a comment here." data-edited="false" rows="10" cols="80"></textarea>
</form>
</div>
<div class="comment-btn-wrapper">
<span class="btn-text preview-comment top-level-preview-btn">Preview</span>
<span class="comment-btn sqs-system-button sqs-editable-button-font sqs-editable-button-shape sqs-button-element--primary">Post Comment…</span>
</div>
<button onclick="CheckComment()">Post</button>
</div>
<script type="text/javascript">
var verbotenList = ["forbidden1", "forbidden2"];
function CheckComment() {
var commentText = document.getElementById("comment").value;
alert(commentText);
var verbotenFound = 0;
for (var i = 0; i < verbotenList.length; i++) {
if (commentText.search(verbotenList[i]) >= 0) {
verbotenFound++;
}
}
alert("verbotenFound=" + verbotenFound);
if (verbotenFound == 0) {
alert("comment approved");
} else {
alert("comment not approved");
}
}
</script>
</body>
</html>
My intention is to periodically update the "verbotenList" with URLs referenced by spammers. My questions again are (1) how to inject the J-script into the Squarespace HTML and (2) how to invoke the Squarespace comment post function once the comment is approved. Thank you for your time.
本文标签: htmlSquarespace programmatically check comment text before postingStack Overflow
版权声明:本文标题:html - Squarespace programmatically check comment text before posting - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744586341a2614218.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论