MCPcopy Create free account
hub / github.com/debbide/GeoFill / fillRadio

Function fillRadio

scripts/content.js:243–258  ·  view source on GitHub ↗

* 处理 radio 按钮

(name, value)

Source from the content-addressed store, hash-verified

241 * 处理 radio 按钮
242 */
243function fillRadio(name, value) {
244 const radios = document.querySelectorAll(`input[type="radio"][name*="${name}" i]`);
245 const searchValue = value.toLowerCase();
246
247 for (const radio of radios) {
248 const radioValue = radio.value.toLowerCase();
249 const labelText = radio.labels?.[0]?.textContent?.toLowerCase() || '';
250
251 if (radioValue.includes(searchValue) || labelText.includes(searchValue)) {
252 radio.checked = true;
253 radio.dispatchEvent(new Event('change', { bubbles: true }));
254 return true;
255 }
256 }
257 return false;
258}
259
260/**
261 * 填写表单(增强版)

Callers 1

fillFormFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected