简体   繁体   中英

Finding input tags and manipulating its attributes

I am trying to make a chrome extension for fun purpose and I am newbie in Google Chrome-extensions. Here is the scenario. I am trying to access the page specific tags eg input and manipulating with their attributes ie assign/change their types.

Could you please give me some helps?

Thanks

You'll need a content script that runs at ( run_at ) the end of the document ( document_end ).

See the docs for more info on that: https://developer.chrome.com/extensions/content_scripts

In your content script, you can just grab all the inputs and do whatever you like with them:

var inputs = document.getElementsByTagName('input');
for(var i = 0, len = inputs.length; i < len; i++) {
    var input = inputs[i];
    input.type = "text"; //etc...
}

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