Warning: fopen(/www/sites/update.greasyfork.icu/index/store/forever/9d0b3a27e449ec5d74e3255a6bc82253.js): failed to open stream: No space left on device in /www/sites/update.greasyfork.icu/index/scriptControl.php on line 65
// ==UserScript==
// @name nicovideo - pause watch history
// @name:ja 視聴履歴に残さない(一時停止)
// @namespace https://greasyfork.org/users/19523
// @description このユーザスクリプトを有効にしている間はニコニコ動画内で動画を再生してもその動画が視聴履歴に残りません(たぶん)
// @include http://www.nicovideo.jp/watch/*
// @include https://www.nicovideo.jp/watch/*
// @version 0.2.2
// @grant none
// @downloadURL none
// ==/UserScript==
function deleteFromHistory() {
var xhr = new XMLHttpRequest();
xhr.open('GET', '/my/history', true);
xhr.send();
xhr.addEventListener('load', function () {
var token = xhr.response.match(/VideoViewHistory.Action\('(..+?)'/)[1];
var videoId = location.pathname.match(/[^/]+$/)[0];
var post = new XMLHttpRequest();
post.open('POST', '/my/history', true);
post.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
post.setRequestHeader('Accept', 'application/json, text/javascript, *; q=0.01');
post.setRequestHeader('x-requested-with', 'XMLHttpRequest');
post.withCredentials = true;
post.responseType = 'json';
post.send('mode=delete&video_id=' + videoId + '&token=' + token + '&innerPage=1');
post.addEventListener('load', function () {
isSent = true;
});
});
}
var isSent = false;
var delay = 15000;
window.addEventListener('load', function () {
if (document.getElementById('external_nicoplayer')) {
setTimeout(deleteFromHistory, delay);
} else {
deleteFromHistory();
}
});
window.addEventListener('beforeunload', function (e) {
if (isSent) {
return;
}
setTimeout(function () {
alert('視聴履歴から削除中...');
}, 0);
deleteFromHistory();
e.returnValue = '視聴履歴から削除中';
// e.preventDefault();
}/*, { passive: false }*/);