Skip to content

Instantly share code, notes, and snippets.

@prinsss
Forked from Last-Order/gist:43199b7a701fc94e800c2de0ed021f1c
Last active May 12, 2026 03:38
Show Gist options
  • Select an option

  • Save prinsss/0c7730cdac336dfeddd3f22da6ad08a5 to your computer and use it in GitHub Desktop.

Select an option

Save prinsss/0c7730cdac336dfeddd3f22da6ad08a5 to your computer and use it in GitHub Desktop.
// ==UserScript==
// @name Abema 强制 1080p
// @description 把其他清晰度的播放列表强制指向1080p
// @version 1.2.0
// @run-at document-start
// @namespace Violentmonkey Scripts
// @match https://abema.tv/*
// @grant none
// ==/UserScript==
const relevantRegex = /\/\d+\/playlist\.m3u8|\/[va]\d+\/.+\.m4s|\/\d+p\.[12]\/.+\.m4s/
const rewrite = (source, url) => {
if (!relevantRegex.test(url)) return url
const next = url
.replace(/\/\d+\/playlist\.m3u8/, '/1080/playlist.m3u8')
.replace(/\/v\d+\/(.+\.m4s)/, '/v1080/$1')
.replace(/\/a\d+\/(.+\.m4s)/, '/a1080/$1')
.replace(/\/\d+p\.1\/(.+\.m4s)/, '/1080p.1/$1')
.replace(/\/\d+p\.2\/(.+\.m4s)/, '/1080p.2/$1')
if (next !== url) {
console.info(`[abema-1080p] ${source} rewrite`)
console.info(` from: ${url}`)
console.info(` to: ${next}`)
} else {
console.info(`[abema-1080p] ${source} already 1080p: ${url}`)
}
return next
}
const originalFetch = window.fetch
window.fetch = (...args) => {
if (typeof args[0] === 'string') args[0] = rewrite('fetch', args[0])
return originalFetch(...args)
}
console.info('[abema-1080p] fetch patched')
const originalOpen = XMLHttpRequest.prototype.open
XMLHttpRequest.prototype.open = function (method, url, ...rest) {
if (typeof url === 'string') url = rewrite('xhr', url)
return originalOpen.call(this, method, url, ...rest)
}
console.info('[abema-1080p] XMLHttpRequest patched')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment