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

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

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

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

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

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

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

(I already have a user script manager, let me install it!)

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.

(I already have a user style manager, let me install it!)

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