2010-07-21 35 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