Force Direct Media Access

Cho phép mở trực tiếp file media từ link ngoài mà không cần truy cập web gốc

Bu betiği kurabilmeniz için Tampermonkey, Greasemonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği kurabilmeniz için Tampermonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği kurabilmeniz için Tampermonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği kurabilmeniz için Tampermonkey ya da Userscripts gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

You will need to install an extension such as Tampermonkey to install this script.

Bu komut dosyasını yüklemek için bir kullanıcı komut dosyası yöneticisi uzantısı yüklemeniz gerekecek.

(Zaten bir kullanıcı komut dosyası yöneticim var, kurmama izin verin!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(Zateb bir user-style yöneticim var, yükleyeyim!)

// ==UserScript==
// @name Force Direct Media Access
// @namespace http://yoursite.example/<br/>// @version 1.0
// @description Cho phép mở trực tiếp file media từ link ngoài mà không cần truy cập web gốc
// @author You
// @match *://*/*
// @grant GM_xmlhttpRequest
// @grant GM_download
// @version 0.0.1.20250912071628
// ==/UserScript==
// @license GNU
(function() {
'use strict';

// Tìm tất cả link media (ảnh, video, audio)
const mediaExtensions = /\.(jpg|jpeg|png|gif|webp|mp4|webm|mp3|wav|ogg)$/i;

document.querySelectorAll("a[href]").forEach(link => {
const href = link.href;
if (mediaExtensions.test(href)) {
link.addEventListener("click", function(e) {
e.preventDefault();
// Mở trực tiếp file trong tab mới
window.open(href, "_blank");
});
}
});

// Tự động thay thế thẻ <img>, <video>, <audio> bị chặn CORS thành blob có thể xem
document.querySelectorAll("img, video, audio").forEach(el => {
if (el.src && mediaExtensions.test(el.src)) {
GM_xmlhttpRequest({
method: "GET",
url: el.src,
responseType: "blob",
onload: function(resp) {
let blobUrl = URL.createObjectURL(resp.response);
el.src = blobUrl;
}
});
}
});
})();