mmmturkeybacon Auto Reload Google IFrame On Error

Automatically reloads the iframe of a Google HIT if the "Please refresh the current page in your browser." error occurs. Adds a reload button in the top right corner of the iframe for Google HITs.

スクリプトをインストールするには、Tampermonkey, GreasemonkeyViolentmonkey のような拡張機能のインストールが必要です。

You will need to install an extension such as Tampermonkey to install this script.

スクリプトをインストールするには、TampermonkeyViolentmonkey のような拡張機能のインストールが必要です。

スクリプトをインストールするには、TampermonkeyUserscripts のような拡張機能のインストールが必要です。

このスクリプトをインストールするには、Tampermonkeyなどの拡張機能をインストールする必要があります。

このスクリプトをインストールするには、ユーザースクリプト管理ツールの拡張機能をインストールする必要があります。

(ユーザースクリプト管理ツールは設定済みなのでインストール!)

このスタイルをインストールするには、Stylusなどの拡張機能をインストールする必要があります。

このスタイルをインストールするには、Stylus などの拡張機能をインストールする必要があります。

このスタイルをインストールするには、Stylus tなどの拡張機能をインストールする必要があります。

このスタイルをインストールするには、ユーザースタイル管理用の拡張機能をインストールする必要があります。

このスタイルをインストールするには、ユーザースタイル管理用の拡張機能をインストールする必要があります。

このスタイルをインストールするには、ユーザースタイル管理用の拡張機能をインストールする必要があります。

(ユーザースタイル管理ツールは設定済みなのでインストール!)

このスクリプトの質問や評価の投稿はこちら通報はこちらへお寄せください
// ==UserScript==
// @name        mmmturkeybacon Auto Reload Google IFrame On Error
// @version     1.02
// @description Automatically reloads the iframe of a Google HIT if the "Please refresh the current page in your browser." error occurs. Adds a reload button in the top right corner of the iframe for Google HITs.
// @author      mmmturkeybacon
// @namespace   http://userscripts.org/users/523367
// @match       https://www.google.com/evaluation/endor/mturk?*
// @require     https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js
// @grant       GM_getValue
// @grant       GM_setValue
// ==/UserScript==

var RELOAD_ATTEMPTS_MAX = 3;
var RELOAD_DELAY = 1000; // milliseconds

$(document).ready(function()
{
        var button_holder = document.createElement("DIV");
        button_holder.style.cssText = "position: fixed; top: 0px; right: 0px; z-index: 20;";
        button_holder.innerHTML = '<input type="button" onclick="window.location.reload(true)" value="Reload" />';
        document.body.insertBefore(button_holder, document.body.firstChild);

        var idx = document.location.href.indexOf('assignmentId=') + 13;
        var assignmentId = document.location.href.substring(idx).split('&')[0];
        if (assignmentId != GM_getValue('mtbgir_assignmentId', 'ASSIGNMENT_ID_NOT_AVAILABLE'))
        {
            GM_setValue('mtbgir_assignmentId', assignmentId);
            GM_setValue('mtbgir_reload_attempts', 0);
        }

        var refresh_page_error = $('p:contains("Please refresh the current page in your browser.")').length > 0;
        var mtbgir_reload_attempts = GM_getValue('mtbgir_reload_attempts', 0);
        if (refresh_page_error && mtbgir_reload_attempts < RELOAD_ATTEMPTS_MAX)
        {
            GM_setValue('mtbgir_reload_attempts', mtbgir_reload_attempts+1);
            setTimeout(function(){window.location.reload(true);}, RELOAD_DELAY);
        }
        else if (refresh_page_error)
        {
            alert('mmmturkeybacon Auto Reload Google IFrame On Error: This page has been automatically reloaded the maximum number of times for this script.');
        }
});