Skip to content

Instantly share code, notes, and snippets.

@tinyx3k
Forked from J2TEAM/youtube.user.js
Created June 14, 2023 07:03
Show Gist options
  • Save tinyx3k/5429907e2bc74d3901d960c79a4950db to your computer and use it in GitHub Desktop.
Save tinyx3k/5429907e2bc74d3901d960c79a4950db 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