Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
372 views
in Technique[技术] by (71.8m points)

javascript - Chrome扩展程序:如何获取表格并填写并提交(Chrome Extension : How to Get a form and fill and submit it)

I am building a chrome extension where I need to get HTML from the website.

(我正在构建一个Chrome扩展程序,需要从网站获取HTML。)

It has a form which needs to be filled and submitted back.

(它的表格需要填写并提交回去。)

I click the extension button, pop up opens.

(我单击扩展按钮,弹出窗口打开。)

I enter details.

(我输入详细信息。)

It fetches me a website which has a form that needs to be filled and submitted back.

(它为我带来了一个网站,该网站的表单需要填写并提交回去。)

I currently am using tabs to open the URL, fill the form and submit it back, but I dont want the user to see all the happenings.

(我目前正在使用标签来打开URL,填写表格并提交回去,但是我不希望用户看到所有情况。)

I also tried Ajax but not sure how exactly to get HTML, fill the inputs and submit it back.

(我也尝试过Ajax,但不确定如何准确地获取HTML,填充输入并将其提交回。)

I tried iFrames but then I get the Unsafe javascript error.

(我尝试了iFrame,但是随后出现了Unsafe javascript错误。)

Not sure I want to use background page as it will be running in the background always.

(不确定我是否要使用后台页面,因为它将始终在后台运行。)

Is there any way I can actually make it happen in the background?

(有什么方法可以使它在后台实际发生?)

Thank You

(谢谢)

  ask by Shari translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Simple REST Client is an extension that allows you to do something similar, you can peek into its source to get some ideas.

(Simple REST Client是一个扩展,允许您执行类似的操作,您可以查看其源代码以获取一些想法。)

Also see Chrome Extension Development - POST to new tab as the first answer shows you how to submit a fake form using JS.

(另请参阅Chrome扩展程序开发-POST到新标签页 ,第一个答案显示了如何使用JS提交假表格。)


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...