在Greasemonkey脚本中的jQuery中添加类 [英] Add class in jQuery in Greasemonkey script
问题描述
我早些时候提出了一个问题,并得到了
I Asked a question earlier and was given a Working solution. One thing I want to do is incorporate jQuery to remove a class F-link-secondary
and replace it with F-rank-good/bad/neutral depending on the value of deltaText.
在大多数页面上,这是我看到的:
On most pages this is what I see:
但是在特定页面上,不存在F-rank-XXX类,而是仅存在一个没有样式的F-link-secondary.
But on a certain page, the F-rank-XXX class is not there and instead there is just a single F-link-secondary which has no style.
这是我想要做的,但是我不确定如何将其与Greasemonkey脚本结合使用.
Here is what I want to do but I am not sure how to incorporate it with the Greasemonkey script.
function getRank(deltaText) {
if((1 <= deltaText) && (deltaText <= 10))
$("???").removeClass("F-link-secondary").addClass("F-rank-good");
if((11 <= deltaText) && (deltaText <= 22))
$("???").removeClass("F-link-secondary").addClass("F-rank-neutral");
if((23 <= deltaText) && (deltaText <= 32))
$("???").removeClass("F-link-secondary").addClass("F-rank-bad");
}
推荐答案
在这种情况下,只需在delinkChangeStat
函数内添加代码.
发件人:
In this case, just add the code inside the delinkChangeStat
function.
From:
//-- Change the link
if (deltaText) {
jNode.text (jNode.text () + " - " + deltaText);
}
收件人:
//-- Change the link
if (deltaText) {
jNode.text (jNode.text () + " - " + deltaText);
var deltaVal = parseInt (deltaText, 10);
if ( (1 <= deltaVal) && (deltaVal <= 10) )
jNode.removeClass ("F-link-secondary").addClass ("F-rank-good");
else if ( (11 <= deltaVal) && (deltaVal <= 22) )
jNode.removeClass ("F-link-secondary").addClass ("F-rank-neutral");
else if ( (23 <= deltaVal) && (deltaVal <= 32) )
jNode.removeClass ("F-link-secondary").addClass ("F-rank-bad");
}
这篇关于在Greasemonkey脚本中的jQuery中添加类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!