Skip to content

Instantly share code, notes, and snippets.

@J2TEAM
Last active October 3, 2023 13:06
Show Gist options
  • Star 6 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save J2TEAM/98f5bb6967d9e01b579db240884b2a51 to your computer and use it in GitHub Desktop.
Save J2TEAM/98f5bb6967d9e01b579db240884b2a51 to your computer and use it in GitHub Desktop.
Tự động đóng tab Youtube khi hết video. Sử dụng bằng cách cài Tampermonkey nhé.
// ==UserScript==
// @name YouTube Auto Close
// @namespace http://j2team.dev/
// @version 0.1
// @description Automatically closes YouTube videos after playback.
// @author JUNO_OKYO
// @match https://www.youtube.com/watch*
// @icon https://www.google.com/s2/favicons?sz=64&domain=youtube.com
// @grant window.close
// ==/UserScript==
(function() {
'use strict';
const video = document.querySelector('.html5-main-video');
if (!video) {
return;
}
video.addEventListener('ended', function() {
console.log('The video has ended.');
window.close();
});
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment