mirror of
https://github.com/clash-verge-rev/clash-verge-rev
synced 2025-05-05 22:13:43 +08:00
37 lines
1.0 KiB
JavaScript
37 lines
1.0 KiB
JavaScript
(function () {
|
|
if (window.matchMedia && window.matchMedia("all").addEventListener) {
|
|
return;
|
|
}
|
|
|
|
const originalMatchMedia = window.matchMedia;
|
|
|
|
window.matchMedia = function (query) {
|
|
const mediaQueryList = originalMatchMedia(query);
|
|
|
|
if (!mediaQueryList.addEventListener) {
|
|
mediaQueryList.addEventListener = function (eventType, listener) {
|
|
if (eventType !== "change" || typeof listener !== "function") {
|
|
console.error("Invalid arguments for addEventListener:", arguments);
|
|
return;
|
|
}
|
|
mediaQueryList.addListener(listener);
|
|
};
|
|
}
|
|
|
|
if (!mediaQueryList.removeEventListener) {
|
|
mediaQueryList.removeEventListener = function (eventType, listener) {
|
|
if (eventType !== "change" || typeof listener !== "function") {
|
|
console.error(
|
|
"Invalid arguments for removeEventListener:",
|
|
arguments
|
|
);
|
|
return;
|
|
}
|
|
mediaQueryList.removeListener(listener);
|
|
};
|
|
}
|
|
|
|
return mediaQueryList;
|
|
};
|
|
})();
|