Skip to content

Instantly share code, notes, and snippets.

@piouc
Last active November 12, 2016 08:07
Show Gist options
  • Save piouc/f51d431c936ad727d339a02d7f886380 to your computer and use it in GitHub Desktop.
Save piouc/f51d431c936ad727d339a02d7f886380 to your computer and use it in GitHub Desktop.
noFlashNicoVideo
(() => {
// Remove flash player notify
const notifyOverlay = document.querySelector('.notify_update_flash_player')
if(notifyOverlay){
document.body.removeChild(notifyOverlay)
}
const videoID = JSON.parse(document.getElementById('watchAPIDataContainer').innerHTML).flashvars.videoId
const playerContainer = document.getElementById('playerContainerWrapper')
removeAllChild(playerContainer)
fetch(`http://flapi.nicovideo.jp/api/getflv?v=${videoID}`, {
mode: 'cors',
credentials: 'include'
}).then(res => res.text()).then(res => {
const video = document.createElement('video')
Object.assign(video, {
src: decodeURIComponent(res.match(/url=([^&]*)/)[1]),
autoplay: true,
controls: true,
style: 'display: block; width: 1008px; margin: 0 auto;'
})
playerContainer.appendChild(video)
})
function removeAllChild(element){
Array.from(element.childNodes).forEach(child => element.removeChild(child))
}
})()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment