Skip to content

Instantly share code, notes, and snippets.

@alaasalama
Last active August 21, 2016 02:36
Show Gist options
  • Save alaasalama/3d441c13617b3cee0e9c6c50edd80f38 to your computer and use it in GitHub Desktop.
Save alaasalama/3d441c13617b3cee0e9c6c50edd80f38 to your computer and use it in GitHub Desktop.
Check's if the post got replied by one of the support team members or not in a bbPress support forum.
// ==UserScript==
// @name parallel-support-check
// @namespace http://alaasalama.com/
// @version 1.0
// @description check if this support thread got a reply or not
// @author Alaa.Salama
// @match https://themify.me/forum/*
// @grant none
// @require https://code.jquery.com/jquery-2.2.4.min.js
// ==/UserScript==
(function() {
'use strict';
// Your code here...
var current_issue = jQuery(location).attr("href");
var interval = 60000;
function fire_my_ajax(){
jQuery(function(){
jQuery.ajax({
type: "GET",
url: current_issue,
success: function(data) {
var text_query = jQuery(data).find('.bbp-replies li:nth-last-child(2) .bbp-threaded-replies .bbp-author-name').text();
if (text_query !== ""){
var filter_reply = jQuery(data).find('.bbp-replies li:nth-last-child(2) .bbp-threaded-replies .bbp-author-name').text();
if (filter_reply.indexOf("Themify") >= 0){
alert("This thread was replied before! by an inline reply.");
}
}
else {
var filter = jQuery(data).find('.bbp-replies li:nth-last-child(2) .bbp-author-name').text();
if (filter.indexOf("Themify") >= 0){
alert("This thread was replied before!");
}
}
},
complete: function (data) {
setTimeout(fire_my_ajax, interval);
}
});
});
}
setTimeout(fire_my_ajax, interval);
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment