简体   繁体   English

如何在Greasemonkey中重新调整recaptcha的大小?

[英]How can I resize the recaptcha in Greasemonkey?

I want to re size the text from the captcha to be easier to see, with Greasemonkey. 我想用Greasemonkey重新调整验证码中的文本大小以便于查看。

How can I do it? 我该怎么做?

For example, I have this captcha: 例如,我有这个验证码:

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

I want to change the height="57" and the width="300" from the second line (from the image style) to 85 and 450 respectively. 我想将第二行(从图像样式)的height="57"width="300"分别更改为85和450。

Changing it into the inspect works correctly, but how can I do to do it always with Greasemonkey? 将其更改为检查工作正常,但如何使用Greasemonkey始终执行此操作?

These userContent.css entries might work: 这些userContent.css条目可能有效:

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

Since this is Greasemonkey, I'm going to assume you're using a reasonably up-to-date version of Firefox. 由于这是Greasemonkey,我假设你正在使用一个合理的最新版本的Firefox。 In which case, you might be able to use querySelector: 在这种情况下,您可以使用querySelector:

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

If that doesn't work, you can try setting the img's attributes instead: 如果这不起作用,您可以尝试设置img的属性:

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

If that doesn't work, you can try setting both the box and the img: 如果不起作用,您可以尝试同时设置框和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");
}

Do: 做:

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

If the recaptcha is in an iframe, then @include the iframe's url, and not the parent's url, but note that this'll probably change the size of recaptcha's on every site, so you may want to check that window.top.location for window.top is the desired location. 如果recaptcha在iframe中,则@include iframe的url,而不是父级的url,但请注意,这可能会改变每个站点上recaptcha的大小,因此您可能需要检查window.top.location window.top是所需的位置。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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