2010-07-21 60 views
5

我想重新调整验证码中的文字大小,使用Greasemonkey更容易看清。我该如何调整Greasemonkey中的recaptcha?

我该怎么办?

例如,我有这样的验证码:

<div id="recaptcha_image" style="width: 300px; height: 57px; "> 
    <img style="display:block;" height="57" width="300" src="http://www.google.com/recaptcha/api/image?c=03AHJ_VuuqeICMpU36GlHCSchBzERwiDzTH4A1RHobtEpbbSK5lWC47EVkgeuF_ause8bnYTHGhjRr_GFiVMh9e4sZFXIBlv4-vcY7WXNjtBHhVmIl2Z5tqK_CY5hRZjtr-MWDUrBOr7mQE0ZqfU8XeeUeXLM5cxcwEQ"> 
</div> 

我想分别到height="57"width="300"从第二线(从图像样式)改变为85和450。

将其更改为正确的检查工作,但我怎样才能始终用Greasemonkey做到这一点?

+0

您无法使用document.getElementById('reaptcha_image')。style.height =“85px”; ?? – mplungjan 2010-07-21 17:39:24

+0

不,不工作=/ – Shady 2010-07-21 17:51:50

+0

请注意,如果您复制并粘贴了mplungjan写入的内容,将无法使用它应该是'document.getElementById('recaptcha_image')。style.height =“85px”;' c是在名称的重述部分缺少。 – qw3n 2010-07-21 18:07:25

回答

2

这些userContent.css项可能的工作:

div#recaptcha_image, 
div#recaptcha_image > img { 
    width: 450px !important; 
    height: 85px !important; 
} 
0

务必:

var img = document.evaluate("//div[@id='recaptcha_image']/img", document, null, 9, null).singleNodeValue; 
img.setAttribute('width', '85'); 
img.setAttribute('height', '450'); 

如果验证码是一个iframe,然后@include iframe的网址,而不是父母的网址,但请注意,这可能会改变的reCAPTCHA的尺寸上的每一个网站,因此您可能需要检查window.top.location是否为window.top是您想要的位置。

1

由于这是Greasemonkey,我会假设您使用的是Firefox的合理更新版本。在这种情况下,您可能能够使用querySelector:

var query = document.querySelector("#recaptcha_image > img"); 
if (query) { 
    query.style.width = "450px !important"; 
    query.style.height = "85px !important"; 
} 

如果不工作,你可以尝试设置IMG的属性而不是:

var query = document.querySelector("#recaptcha_image > img"); 
if (query) { 
    query.setAttribute("width", "450"); 
    query.setAttribute("height", "85"); 
} 

如果不起作用,你可以尝试设置框和IMG都:

var element = document.getElementById("recaptcha_image"); 
if (element) { 
    element.style.width = "450px !important"; 
    element.style.height = "85px !important"; 
} 

var query = element.querySelector("img"); 
if (query) { 
    query.setAttribute("width", "450"); 
    query.setAttribute("height", "85"); 
} 
+0

@idealmachine:在您给我的链接中,它指出您需要单独设置每个样式,并且setAttribute不起作用。也许你误解了它? – Pauan 2010-10-15 18:47:49

+0

你是对的,我*确实误读了它。它是*自定义属性*,需要使用setAttribute进行设置。 http://commons.oreilly.com/wiki/index.php/Greasemonkey_Hacks/Getting_Started#Pitfall_.2310:_style – PleaseStand 2010-10-15 19:33:10