Greasy Fork

GameFAQs Daily Poll Radio Buttons

Changes GameFAQs Poll to use radio button display

目前为 2019-03-27 提交的版本。查看 最新版本

// ==UserScript==
// @name     GameFAQs Daily Poll Radio Buttons
// @description Changes GameFAQs Poll to use radio button display
// @version  1
// @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++) {
        po_blocks[i].addEventListener("click", potd_radio_buttons);
        var po_box = po_blocks[i].getElementsByClassName('po_box')[0];
        if (po_box.innerText == '☒' || po_box.innerText == '☑') {
            selected = true;
        } else {
            selected = false;
        }
        po_box.innerText = '';
        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();