So every answers regarding this problem is like:
You cant do it unless you own the video and turn off the adsense yourself.
But i see a possibility.
This is how adblockers works. When i ran chrome inspecter with adblockplus, i saw all the ad script requests blocked,
i want to replicate the same but "in the website itself" using javascript
So that it will automatically block all ads.
Now why i want to do this ? because in my website, i dont want to annoy people with ads
Any solution ?
So every answers regarding this problem is like:
You cant do it unless you own the video and turn off the adsense yourself.
But i see a possibility.
This is how adblockers works. When i ran chrome inspecter with adblockplus, i saw all the ad script requests blocked,
i want to replicate the same but "in the website itself" using javascript
So that it will automatically block all ads.
Now why i want to do this ? because in my website, i dont want to annoy people with ads
Any solution ?
Share Improve this question edited Nov 22, 2018 at 14:37 Linda Lawton - DaImTo 117k38 gold badges220 silver badges496 bronze badges asked Nov 22, 2018 at 14:32 SubrataSubrata 571 gold badge1 silver badge8 bronze badges 3- you still cannot for a video embedded in an iframe (unless you own the youtube domain, which i doubt), because you can't control its javascript. If you share other people's content, you share what comes with it.. as simple as that – Kaddath Commented Nov 22, 2018 at 14:35
- but adblockers does it right ? what am i missing ? – Subrata Commented Nov 22, 2018 at 14:37
- possibly to hardcode a script that blocks every script received from googleads.g.doubleclick.net........ – Subrata Commented Nov 22, 2018 at 14:39
2 Answers
Reset to default 15Run this in your console.
const clear = (() => {
const defined = v => v !== null && v !== undefined;
const timeout = setInterval(() => {
const ad = [...document.querySelectorAll('.ad-showing')][0];
if (defined(ad)) {
const video = document.querySelector('video');
if (defined(video)) {
video.currentTime = video.duration;
}
}
}, 500);
return function() {
clearTimeout(timeout);
}
})();
// clear();
The only solution to achieve this -- is to make a browser extension like all adblocker do.
They are able to work because they are injecting javascript into every page and, roughly speaking, act like their javascript was served by YouTube themselves.