1
I have a code that should work at a certain time, but it is not working.
$(function() {
$(".post").each(function() {
var d = new Date();
var hora = d.getHours();
if (hora <= 7 && hora >= 22) {
alert("O código está funcionando!");
if (_userdata.user_level == 2 || _userdata.user_level == 1) {
return;
}
if ($('.pathname-box:contains(Tarefas), .pathname-box:contains(Redações)').length > 0) {
var username = _userdata.username;
if ($(this).has('.staff').length) {
return;
}
if ($(this).html().indexOf(username) <= 1) {
$(this).remove();
}
if ($(this).html().indexOf(username) >= 1) {
$(this).remove();
}
}
}
});
});
Part of setting the time:
var d = new Date();
var hora = d.getHours();
if (hora <= 7 && hora >= 22) {
Observing: If I remove the part where you set the time when the code should work, it starts working so it can’t be code problem.
Code without schedule:
$(function() {
$(".post").each(function() {
alert("O código está funcionando!");
if (_userdata.user_level == 2 || _userdata.user_level == 1) {
return;
}
if ($('.pathname-box:contains(Tarefas), .pathname-box:contains(Redações)').length > 0) {
var username = _userdata.username;
if ($(this).has('.staff').length) {
return;
}
if ($(this).html().indexOf(username) <= 1) {
$(this).remove();
}
if ($(this).html().indexOf(username) >= 1) {
$(this).remove();
}
}
}
});
});
That condition
if (hora <= 7 && hora >= 22) {
is impossible. What is the number that is at once less than or equal to seven and greater than or equal to 22? Do you want to use the or? ie:||
– Sergio
That’s what it was! Thanks.
– Maradinho PH