2012-02-26 10 views
1

Greasemonkeyで(テキスト名)を自動的に変更したい。Greasemonkeyでテキストを自動的に変更するにはどうしたらいいですか?

たとえば、「ボクシング」と「キックボックス」の代わりに「偽」を表示したいとします。

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

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

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

私はこのコードを変更したい:として最高の私が解釈できるよう

<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> 

答えて

1

実際のページのpastebinを明確にしてリンクしてください。

// ==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); 
} 
関連する問題