Export times from Cube Timer

Exports a list of times to import on Twisty Timer

当前为 2017-09-09 提交的版本,查看 最新版本

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name        Export times from Cube Timer
// @namespace   cubetimer
// @description Exports a list of times to import on Twisty Timer
// @include     http://www.cubetimer.com/
// @author      SoKeT
// @version     1
// ==/UserScript==

let selector = "body > table:nth-child(3) > tbody:nth-child(1) > tr:nth-child(1) > td:nth-child(2)";
let $container = $(selector);
let $button = $("<button id='export-times'>Export times</button>").appendTo($container);;
let $download = $("<a id='download' download='times.txt' style='display: block'>Download</a>").appendTo($container).hide();

$button.click(function() {
  let formattedList = "";
  
  $.each(time_list, function(index, value) {
    let time = Math.floor((value / 1000) * 100) / 100;
    let date = new Date();
    let formattedTime = '"' + time + '"; ""; "' + date.toISOString() + '"\r\n';
    formattedList += formattedTime;
  });

  let file = createFile(formattedList);
  $download.attr("href", file).show();
});

function createFile(text) {
  let data = new Blob([text], {type: "octet/stream"});
  let file = window.URL.createObjectURL(data);
  return file;
};