I'm having an issue where the DVD/Games and General items are being ignored and everything is flagged as a jewelry item as it's only reading the first if statement. What am I doing incorrectly? Is it an issue with the :contains? The first function makes it so it doesn't matter if DVD is lowercase, upper or mixed. Many thanks.
In this example. DVD should be found and then Game / DVD / Blu-Ray should be displayed in #biic-item-type instead of Jewellery
setTimeout(
function()
{
$.expr[":"].contains = $.expr.createPseudo(function(arg) {
return function( elem ) {
return $(elem).text().toUpperCase().indexOf(arg.toUpperCase()) >= 0;
};
});
if ($("#content-body:contains('white gold'), #content-body:contains('yellow gold'), #content-body:contains('bracelet'), #content-body:contains('necklace'), #content-body:contains('charm'), #content-body:contains('pendant'), #content-body:contains('bangle'), #content-body:contains('diamond')").length) {
$('#marketing').append('<img id="tradeandsaveimage" src="chrome-extension://oglkppenbgclfdedmogeodheocmeeafa/images/advertising/Trade-and-Save-Logo.jpg?w=803&h=603" width="804" height="604" />');
$('#biic-item-type').text('Jewellery').addClass('bit-jewellery');
} else if ($("#content-body:contains('dvd'), #content-body:contains('game disc'), #content-body:contains('game cartridge'), #content-body:contains('blu-ray disc')").length) {
$('#marketing').append('<img id="tradeandsaveimage" src="chrome-extension://oglkppenbgclfdedmogeodheocmeeafa/images/advertising/Trade-and-Save-Logo.jpg?w=803&h=603" width="804" height="604" />');
$('#biic-item-type').text('Game / DVD / Blu-Ray').addClass('bit-dvd');
} else {
$('#marketing').append('<img id="warrantyimage" src="chrome-extension://oglkppenbgclfdedmogeodheocmeeafa/images/advertising/Warranty-90-Day-Logo.jpg?w=803&h=603" width="804" height="604" /><img id="tradeandsaveimage" src="chrome-extension://oglkppenbgclfdedmogeodheocmeeafa/images/advertising/Trade-and-Save-Logo.jpg?w=803&h=603" width="804" height="604" />');
$('#biic-item-type').text('General Stock').addClass('bit-general');
}
// var descweightnext = $("#item-pre-description div p strong:contains('Weight')");
// if (descweightnext.length) {
// var bono = descweightnext.next('span').text();
// };
// $('#item-weight').text(bono);
}, 500);
div#biic-item-type {
float: left;
padding: 5px 10px;
font-size: 16px;
min-width: 86px !important;
color: #fff;
min-height: 16px;
text-align: center
}
.bit-jewellery { background: #650080; }
.bit-dvd { background: #6161a3; }
.bit-general { background: #93102e; }
#content-body { display: none; }
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div id="biic-item-type"></div>
<div id="content-body">
<div id="item-weight"></div>
<div id="header-split-left">
<div id="item-title">
This Is 40 (000200195437)
</div>
<div id="item-category">
DVD<br> </div>
</div>
<div id="header-split-right">
<div id="item-product-number-copy">
000200195437 </div>
</div>
<div id="the-body-stats">
<div id="item-price">
$6<sup>.00</sup><br> </div>
<div id="description-paste-here">Product details:
Item Number: 000200195437
Title: This Is 40
Box Set: No
</div>
</div>