简体   繁体   中英

How can I change text automatically with Greasemonkey?

I want to change (text name) automatically with Greasemonkey.

For example, I want to see "false" instead of "Boxing" and "Kickbox".

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

< text >Kickbox< /text > = < text >false< /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);
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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