Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Chrome extension to access source code of any website

I'd like to write an extension that will display a popup with a text box, where you enter a word, then the number of occurrences of this word on the current page's source code is displayed. How would I access the current page's source code? Do I have to add a permission in the manifest?

like image 834
Gerals Avatar asked Dec 02 '25 18:12

Gerals


1 Answers

I think you can't. You can access the page's DOM source:

document.body.InnerHTML
document.head.InnerHTML

Though this is different from page source, because it contains results of JavaScript.

If you want to get the page source, you can just fire a XMLHTTPRequest at the page and search the results.

To get the current tab's URL you need the "tabs" permission. To download pages in the background page you need the "http://*/*" and (if you like) "https://*/*" permissions.

like image 174
paztulio Avatar answered Dec 05 '25 07:12

paztulio



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!