Clear BLOCK table in HITDB

Completely empty the BLOCK table in HITDB

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name        Clear BLOCK table in HITDB
// @namespace   localhost
// @description Completely empty the BLOCK table in HITDB
// @include     https://www.mturk.com/mturk/dashboard
// @require		http://code.jquery.com/jquery-2.1.1.js
// @version     1.0.1
// @grant       none
// ==/UserScript==
var HITStorage = {};
var indexedDB = window.indexedDB || window.webkitIndexedDB || window.mozIndexedDB;
window.IDBTransaction = window.IDBTransaction || window.webkitIDBTransaction || window.mozIDBTransaction;
window.IDBKeyRange = window.IDBKeyRange || window.webkitIDBKeyRange || window.mozIDBKeyRange;

var IDBKeyRange = window.IDBKeyRange;

HITStorage.indexedDB = {};
HITStorage.indexedDB = {};
HITStorage.indexedDB.db = null;

HITStorage.indexedDB.onerror = function(e) {
  console.log(e);
};
var v = 4;

HITStorage.indexedDB.deleteBLOCKS = function () {
  var request = indexedDB.open("HITDB", v);
  console.log("request starting");
  request.onsuccess = function(e) {
    
    HITStorage.indexedDB.db = e.target.result;
    var db = HITStorage.indexedDB.db;
	  var trans = db.transaction(["BLOCKS"], "readwrite");
    var clearRequest = trans.objectStore("BLOCKS").clear();    
    clearRequest.onsuccess = function (e) {
      alert("BLOCKS deleted!");
    }
  }
}

$('body').append("<button id='deleteBlocks' >Delete Blocks</button>");

$(document).on('click', '#deleteBlocks', function () {
  console.log("Deleting blocks");
  HITStorage.indexedDB.deleteBLOCKS();
});