@cagatay This is a bit experimental currently, but the below jQuery
should detect correctly when the HTML being targeted has no class.
Can you please try replacing the below you previously inserted
$(window).on('action:ajaxify.loaded', function(data) {
$(document).ready(function() {
if (!$('li[component="post"]').hasClass('.topic-owner-post') || (!$('li[component="post"]').hasClass('.self-post'))) {
console.log("Adding required classes for messenger type view");
$('li[component="post"]').addClass('topic-response-post');
}
});
});
$(window).on('action:ajaxify.end', function(data) {
$(document).ready(function() {
if (!$('li[component="post"]').hasClass('.topic-owner-post') || (!$('li[component="post"]').hasClass('.self-post'))) {
console.log("Adding required classes for messenger type view");
$('li[component="post"]').addClass('topic-response-post');
}
});
});
with
// Target those elements already loaded in the DOM
$(document).ready(function() {
$(window).on('action:ajaxify.end', function(data) {
if ($('li[component="post"]').hasClass("")) {
console.log("Adding required classes for messenger type view");
$('li[component="post"]').addClass('topic-response-post');
}
});
});
// Target elements dynamically added to the DOM on post load
$(document).ready(function() {
$(window).on('action:ajaxify.loaded', function(data) {
if ($('li[component="post"]').hasClass("")) {
console.log("Adding required classes for messenger type view");
$('li[component="post"]').addClass('topic-response-post');
}
});
});
Try it and let me know.