Greasy Fork

nicovideo - pause watch history

ユーザスクリプト有効中に見たニコニコ動画の動画が視聴履歴が残らないようにします。

当前为 2019-02-03 提交的版本,查看 最新版本

// ==UserScript==
// @name        nicovideo - pause watch history
// @name:ja     視聴履歴を残さない(一時停止)
// @namespace   https://greasyfork.org/users/19523
// @description ユーザスクリプト有効中に見たニコニコ動画の動画が視聴履歴が残らないようにします。
// @include     https://www.nicovideo.jp/watch/*
// @version     0.1
// @grant       none
// ==/UserScript==


(function () {
  if (typeof jQuery === "undefined") {
    var s1 = document.createElement('script');
    s1.src = 'https://nicovideo.cdn.nimg.jp/uni/js/lib/jquery/jquery-1.7.min.js';
    document.getElementsByTagName('head')[0].appendChild(s1);
  }
})();

window.addEventListener('load', function () {
  var s2 = document.createElement('script');
  s2.innerHTML = `
    jQuery.ajax({
      type: 'GET',
      url: location.protocol + '//www.nicovideo.jp/my/history',
      success: function (response) {
        var token = response.match(/VideoViewHistory.Action\\('(..+?)'/)[1];
        var videoId = location.pathname.match(/[^/]+$/)[0];
        var data = {
          'mode': 'delete',
          'video_id': videoId,
          'token': token,
          'innerPage': 1
        };

        jQuery.ajax({
          type: 'POST',
          url: location.protocol + '//www.nicovideo.jp/my/history',
          data: data,
          dataType: 'json',
          success: function (response) {
            console.log('done', response);
          },
          error: function (response) {
            console.log('fail', response);
          }
        });
      },
      error: function (response) {
        console.log('fail', response);
      }
    });
  `;
  document.getElementsByTagName('head')[0].appendChild(s2);
});