简体   繁体   English

如何使用Greasemonkey自动更改文本?

[英]How can I change text automatically with Greasemonkey?

I want to change (text name) automatically with Greasemonkey. 我想使用Greasemonkey自动更改(文本名称)。

For example, I want to see "false" instead of "Boxing" and "Kickbox". 例如,我想查看“ false”,而不是“ Boxing”和“ Kickbox”。

< text >Boxing< /text > = < text >false< /text > < text >Boxing< /text > = < text >false< /text >

< text >Kickbox< /text > = < text >false< /text > < text >Kickbox< /text > = < text >false< /text >

< text >Football< /text > = < text >true< /text > < text >Football< /text > = < text >true< /text >

I want to change this code: 我想更改此代码:

< questions >
    < question id="5" >
        < text >Which is playing with ball ?< /text >
        < answer id="10" >
            < text >Boxing< /text >
        < /answer >
        < answer id="11" >
            < text >Football< /text >
        < /answer >
        < answer id="12" >
            < text >Kickbox< /text >
        < /answer >
    < /question >
< /questions >

As best as I can interpret the question (please clarify and link to the actual page or a pastebin of the actual page, here is a complete script that changes those values: 尽我所能解释问题(请澄清并链接到实际页面或实际页面的粘贴框 ,这是一个完整的脚本,可更改这些值:

// ==UserScript==
// @name     _Automatically change answer text
// @include  http://YOUR_SERVER/YOUR_PATH/*
// @require  http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js
// ==/UserScript==

changeAnswerText ("Boxing",     "false");
changeAnswerText ("Kickbox",    "false");


function changeAnswerText (oldText, newText) {
    //-- oldText is case-sensitive.
    var answers = $("questions answer text:contains('" + oldText + "')");
    answers.text (newText);
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM