Greasy Fork is available in English.

Discussões » Criação de Solicitações

Automatically close the tab, if the script finds certain TEXT

§
Publicado: 25/07/2021

How to make so that tab Automatically close, if the script finds certain text

For example: “Video unavailable”
*Message on YouTube

Please Help.
Thx

§
Publicado: 25/07/2021
Editado: 25/07/2021

// ==UserScript==
// @name Close "Video unavailable" YT videos
// @namespace CloseUnavailable
// @version 0.1
// @description Auto closes "Video unavailable" YT videos.
// @author hacker09
// @match https://www.youtube.com/watch?v=*
// @grant window.close
// @run-at document-end
// ==/UserScript==

setTimeout(function(){ //Starts the setTimeout function
if (document.querySelector("#reason").innerText === "Video unavailable") //If the reason for the YT video not being played it equals "Video unavailable"
{ //Starts the if condition
window.top.close(); //Close the link
} //Finishes the if condition
}, 3000); //Finishes the setTimeout function

§
Publicado: 25/07/2021

"hacker09" Thank you!
Everything works.

Publicar resposta

Faça o login para publicar uma resposta.