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

K instalaci tototo skriptu si budete muset nainstalovat rozšíření jako Tampermonkey, Greasemonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Userscripts.

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

K instalaci tohoto skriptu si budete muset nainstalovat manažer uživatelských skriptů.

(Už mám manažer uživatelských skriptů, nechte mě ho nainstalovat!)

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.

(Už mám manažer uživatelských stylů, nechte mě ho nainstalovat!)

// ==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;
}
});
}
});
})();