With the recent efforts YouTube have been taking to stop adblockers it seems they have now e for the chrome extensions that skip the ads instead. As of 2024/1/17 it seems like they have pletely disabled any automated methods I can e up with to press the "skip ad" button
I am by no means experienced in js but have managed to e up with a few things, so far I have tried all of:
const click = (clazz) => {
const buttons = document.getElementsByClassName(clazz);
for (const button of buttons) {
console.log(button)
button.click()
button.dispatchEvent(
new MouseEvent('click')
);
}
};
click("ytp-ad-skip-button-modern")
and the equivalent using subsequent mousedown/up
and pointerdown/up
events, none of which seem to work
I thought perhaps there was some hidden check that the button was being hovered over and so included:
const mouseover = (clazz) => {
const buttons = document.getElementsByClassName(clazz);
for (const button of buttons) {
console.log(button)
button.dispatchEvent(
new MouseEvent('mouseover')
);
}
};
mouseover('ytp-ad-skip-button-modern')
This indeed changes the skip button's opacity as one would expect from the mouseover event, but still no luck in actually skipping.
It feels like me vs Google at this point, anyone got any ideas?
With the recent efforts YouTube have been taking to stop adblockers it seems they have now e for the chrome extensions that skip the ads instead. As of 2024/1/17 it seems like they have pletely disabled any automated methods I can e up with to press the "skip ad" button
I am by no means experienced in js but have managed to e up with a few things, so far I have tried all of:
const click = (clazz) => {
const buttons = document.getElementsByClassName(clazz);
for (const button of buttons) {
console.log(button)
button.click()
button.dispatchEvent(
new MouseEvent('click')
);
}
};
click("ytp-ad-skip-button-modern")
and the equivalent using subsequent mousedown/up
and pointerdown/up
events, none of which seem to work
I thought perhaps there was some hidden check that the button was being hovered over and so included:
const mouseover = (clazz) => {
const buttons = document.getElementsByClassName(clazz);
for (const button of buttons) {
console.log(button)
button.dispatchEvent(
new MouseEvent('mouseover')
);
}
};
mouseover('ytp-ad-skip-button-modern')
This indeed changes the skip button's opacity as one would expect from the mouseover event, but still no luck in actually skipping.
It feels like me vs Google at this point, anyone got any ideas?
Share Improve this question asked Jan 18, 2024 at 0:12 Pet'liPet'li 493 bronze badges2 Answers
Reset to default 8I noticed a similar change in behavior on YouTube around that same timeframe. I was able to get a programmatic .click()
approach working in one browser (Chrome - logged into YouTube), but not another (Edge - logged out).
In debugging further I believe this is due to an experiment that YouTube is running.
YouTube's https://www.youtube./s/player/31eb286a/player_ias.vflset/en_US/base.js file has a string with value ab_sa_ef
. I believe this to be an identifier for a particular experiment. You will find this string in the onClick
handler of the Skip button. Pay particular attention to this line:
if (!this.api.U().L("ab_sa_ef") || 0 !== RG(a, { contentCpn: b }))
I read that as "if you are in the ab_sa_ef
experiment then check the RG()
function before executing the result of a click."
That RG()
function has an interesting line:
!0 === a.isTrusted ? d.push("BISCOTTI_BASED_DETECTION_STATE_IS_CLICK_EVENT_TRUSTED")
Notice that for people in this experiment YouTube is now looking at the value of the isTrusted
property on the event. Per the W3C spec the isTrusted
property is used to distinguish between events fired via the user vs. programmatically.
I have yet to e up with a way to get around this distinction when it is used. I find it interesting that this is only an experiment and it has been running for at least a month. I wonder if there is some sort of downside that prevents them from rolling it out to all users.
I have no idea what changed, but button.click() now works. It was either something to do with async functions or getting the class name of the button wrong. Sorry I can't be of any more help but I have absolutely zero clue