Skip to content

Commit

Permalink
Create ad_lite.js
Browse files Browse the repository at this point in the history
  • Loading branch information
litvcom authored Nov 5, 2024
1 parent eca5dab commit 73028da
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions ad_lite.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
(function () {
'use strict';

if (typeof Lampa?.Platform?.tv === 'function') {
Lampa.Platform.tv();
}

let initMarker = false;

function removeAds() {
document.querySelectorAll('.ad-bot, .ad_bot, .ad-server').forEach(ad => ad.remove());
document.querySelectorAll('.open--broadcast, .open--feed, .open--premium, .open--notice').forEach(el => el.remove());
}

function hideElements() {
$('.selectbox-item__lock').parent().hide();
$('.settings-param-title').last().hide();
}

const observer = new MutationObserver((mutationsList) => {
const hasCardElements = document.getElementsByClassName('card').length > 0;
if (hasCardElements && !initMarker) {
initMarker = true;
setTimeout(hideElements, 50);
setTimeout(() => initMarker = false, 500);
}

removeAds();
});

observer.observe(document.body, { childList: true, subtree: true });

removeAds();
})();

0 comments on commit 73028da

Please sign in to comment.