1300

移行用のテストです

ニコニコ動画の履歴ページから動画のURLをコピー

期間指定あり

// ==UserScript==
// @name         nico_history_copy
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  try to take over the world!
// @author       You
// @match        https://www.nicovideo.jp/my/history
// @grant        none
// ==/UserScript==
var result = document.evaluate('//p[@class="posttime"]/text()', document, null, 7, null);
var g_time;
var d_time = [];
for (var i = 0; i < result.snapshotLength; i++) {
  g_time = result.snapshotItem(i).nodeValue.replace("年", "/");
  g_time = g_time.replace("月", "/");
  g_time = g_time.replace("日", "");
  g_time = g_time.replace(" 視聴", "");
  var d1 = new Date(g_time).getTime();
  //console.log(Math.floor(d1/1000));
  d_time[i] = Math.floor(d1 / 1000);
}
var result2 = document.evaluate('//input[@class="miniSearchWord"]', document, null, 7, null);
var result3 = document.evaluate('//p[@class="posttime"]/following-sibling::h5/a', document, null, 7, null);
result2.snapshotItem(0).addEventListener('change', function () {
  if (result2.snapshotItem(0).value == "copy") {
    var s_time = window.prompt("start", "2010/1/23");
    var d2 = new Date(s_time).getTime();
    console.log(d2);
    var t_time = new Date();
    var yy = t_time.getFullYear();
    var mm = t_time.getMonth() + 1;
    var dd = t_time.getDate();
    var td_time = yy + "/" + mm + "/" + dd;
    var f_time = window.prompt("finish", td_time);
    var d3 = new Date(f_time).getTime();
    console.log(d3);
    var u_list = "";
    var flag = 0;
    for (i = 0; i < d_time.length; i++) {
      if (d_time[i] > Math.floor(d2 / 1000)) {
        if (d_time[i] < Math.floor(d3 / 1000)) {
          u_list = u_list + " " + result3.snapshotItem(i).href;
          flag = 1;
        }
      }
    }
    if (flag == 1) {
      var sign = window.prompt("url_list", u_list);
    } else {
      alert("なにかが変です");
    }
  }
});

期間指定なし

var result3 = document.evaluate('id("historyList")//h5/a', document, null, 7, null);
var u_list = "";
for (var i = 0; i < result3.snapshotLength; i++) {
  u_list = u_list + " " + result3.snapshotItem(i).href;
}
var result = document.evaluate('//p[@class="posttime"]', document, null, 7, null);
result.snapshotItem(0).insertAdjacentHTML("beforeend", "<a href='javascript:void(0);'><img src='https://cdn-ak.f.st-hatena.com/images/fotolife/j/jigendaddy/20181023/20181023214613.png'></a>");
var result2 = document.evaluate('//p[@class="posttime"]/a', document, null, 7, null);
result2.snapshotItem(0).addEventListener('click', sample, false);

function sample() {
  var sign = window.prompt("url_list", u_list);
}