GameFAQs Daily Poll Radio Buttons

Changes GameFAQs Poll to use radio button display

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name     GameFAQs Daily Poll Radio Buttons
// @description Changes GameFAQs Poll to use radio button display
// @version  1.2
// @grant    none
// @include https://gamefaqs.gamespot.com/
// @namespace https://greasyfork.org/users/5885
// ==/UserScript==
function potd_radio_buttons() {
    var po_blocks = document.getElementsByClassName('po_block');
    var selected = false;
    var disable_buttons = false;
    var disabled = document.getElementsByClassName('po_disabled');
    if (disabled.length > 0) {
        disable_buttons = true;
    }
    for (var i = 0; i < po_blocks.length; i++) {
        if (!disable_buttons) {
            po_blocks[i].addEventListener("click", potd_radio_buttons);
        }
        var po_box = po_blocks[i].getElementsByClassName('po_box')[0];
        if (po_box.textContent == '☒' || po_box.textContent == '☑') {
            selected = true;
        } else {
            selected = false;
        }
        po_box.textContent = '';
        var input = document.createElement('input');
        input.setAttribute("type", "radio");
        input.setAttribute("name", "gfaqs_poll");
        if (disable_buttons) {
            input.setAttribute("disabled", "disabled");
        }
        if (selected) {
            input.setAttribute("checked", "checked");
        }
        po_box.appendChild(input);
    }
}
potd_radio_buttons();