Last active
January 6, 2017 03:42
-
-
Save a4lg/2cbb5caf2153ceddca145b544ec5e9b5 to your computer and use it in GitHub Desktop.
Greasemonkey/Tampermonkey 用ニコニコ動画プレイヤー (HTML5) のレジューム機能を無効化するスクリプト
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name Disable resume feature on Nicovideo HTML5 player | |
// @description ニコニコ動画プレイヤー (HTML5) のレジューム機能を無効化 | |
// @namespace http://a4lg.com/ | |
// @version 1.1 | |
// @include http://www.nicovideo.jp/watch/* | |
// @author a4lg | |
// @license CC0 | |
// @run-at document-start | |
// ==/UserScript== | |
var observer2 = new MutationObserver(function(event) | |
{ | |
var dataElement = document.getElementById("js-initial-watch-data"); | |
if (dataElement) | |
{ | |
var data = JSON.parse(dataElement.getAttribute("data-api-data")); | |
data.context.initialPlaybackPosition = null; | |
data.context.initialPlaybackType = null; | |
dataElement.setAttribute("data-api-data", JSON.stringify(data)); | |
observer2.disconnect(); | |
} | |
}); | |
var observer1 = new MutationObserver(function(event) | |
{ | |
if (document.body) | |
{ | |
observer1.disconnect(); | |
observer2.observe(document.body, {childList:true}); | |
} | |
}); | |
observer1.observe(document.documentElement, {childList:true}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Version 1.1: Firefox で正しく動かない問題を解決