简体   繁体   中英

need small javascript for greasemonkey

HI, i need a greasemonkey code for a web page. The page has hidden input type and value. I need a gm script which can alert the value of the hidden input object as soon as the page loads.

The input tag is present in a form with:

form id="bloog" method="post" action= "/newpage.php" name="bloog">

The hidden content is present as:

<input type="hidden" value="abcd" name="ans">

now as soon as the page loads the value abcd must come in the alertbox.. some body please help me i've been trying for these...

Something like this might work.

// ==UserScript==
// @name          Script Name Here
// @namespace     http://www.yourdomain.com
// @description   An Greasemonkey script that hides alerts hidden field value
// @include       *
// ==/UserScript==

var inputs = document.getElementsByTagName('input');

for (i=0; i<inputs.length; i++) {
  if (inputs[i].getAttribute("name") == "ans") {
    alert(inputs[i].getAttribute("value"));
  }
}

Read Get Started With Greasemonkey on WebMonkey

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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