How to detect view-source scheme in Chrome Extension - google-chrome-extension

I wish to run a content script when viewing the source of any web page. (and have a page action icon appear)
The docs here don't mention view-source as a valid scheme.
Is there a way around this limitation?

You cannot insert a content-script into view-source: pages. I didn't found a detailed explanation, but here is the related commit.

Related

chrome extension: which page getBackgroundPage() retrieve?

I am a little confused whether this api suits my need. I want a common place to view my logs, instead of going around to the popup's console, the background page's console, etc...
Then I noticed that you can include several background scripts. In which case, which page does the api give us?
Chrome does not support multiple background pages in a chrome extension. It supports multiple background scripts. But it does not supports both background page and background scripts at the same time. See below the screenshots.
Error shown when we try add background page and script at the same
time.
Error shown when we try add multiple background pages.
Now coming back to your question which page getBackgroundPage() retrieve?
Since chrome supports only one background page it will return the only page that you include in you manifest.json.

Preloading web pages

I want to write a module? an addon? a plugin? an extension? to a web browser, which will preload all web pages by links, which could be found on a "current" web page - a web page on which user is currently on. After, if user want to switch to some other web page by a link from "current", browser should just open that preloaded page from somewhere, where we store preloaded pages, and do the same actions from new " current ". So, the question is, which of above variants (module? an addon? a plugin? an extension?) could solve my problem, (because as I understand, some of them can have limited functions), or maybe I have to edit the source code of browser, and which browser would you suggest to work with? And if you know any information source, which could help me in understanding how to implement it, I'd be grateful if you post a link! (I'd really appreciate a full answer, because I didn't found much info on the internet about this theme). Thank you!

how to get the debug information for chrome extension

I write a DOM tree protecter Chrome extension to examine if the DOM tree changes. I have the js files in background_page, how can i get those console.logs() in other test html files? What I can only find now is the debug information of chrome://extensions/ when i click on generated_background_page.html. So how can I get information of other webpages? Thanks for replying.
One thing I have found very useful when debugging chrome extensions is to use the "inspect element" feature of the chrome developer tools. If you have a page or an element (such as on a popup from your extension) that you want to debug:
Open up Developer Tools
Wait for your popup to appear (if its not already up)
Switch to the Elements view on Developer Tools
Click the magnifying glass at the bottom so you can select an element
Click on an element in the page you want to debug (e.g. the popup page)
Now your Sources view and other views line up to match the element you've clicked on. The console will now let you look at variables in that context.
If you are not able to get the extension to work, there could be a whole host of reasons.
Are all your scripts loaded form the extension's directory or are you serving
them from a site? Chrome will not load scripts from an external site
unless over https AND after the site that is serving the script has
been whitelisted. See the Chrome Content Security
Policy
for more info.
To inspect the DOM, you need to inject a content script into the page that is being loaded. Are you sure you are doing this correctly? The manifest.json must be done right or else your content script will not get loaded.
For your content script and extension to communicate, you must post and receive messages. More information is available here.
Perhaps the best suggestion I have is that you follow the Chrome extension "tutorial" carefully until you have something working and then amend it to suit your needs.

Programmatic way to search a page for the user in a browser

I am working on a search engine project that will point a user to a page from, say Google, and show them where their search terms are in the document. Most of us search Google and know that sometimes you have to CTRL-F to find where that word appeared on the page (especially on long pages). I know some browser plug-ins can help with this - but is there a way to wrap the page in a frame and do it (even if you don't control the site being displayed)?
If not, what browser plug-ins might you recommend that I could customize & brand so the user can accomplish this task? I'm guessing you could also write a Kinitex plug-in or GreaseMonkey script - but I'd prefer to not go any route that a newbie user wouldn't immediately understand.
Thanks in advance for your help!
You can get source code of the page with curl, add javascript function to it and then pass result to the user. Just like server-side GreaseMonkey. :)
In google Chrome try Google Quick Scroll, it does it.

How does GMail display the sidebar?

You know, like the "Compose Mail," "Inbox," "Sent Mail," etc., on the left hand-side when you load up GMail? I did a search for "Compose Mail" in the page source and got nothing.
The Gmail interface uses JavaScript to dynamically load a lot of stuff. That explains why you don't see "Compose Mail".
If you want to see how the final HTML document looks like, then here is my method:
Install the "Web developer" Firefox extension
Click Tools> Web Developer> View Source> View Generated Source
It's all Javascript. Here's how you can get at that information yourself: if you don't already use Firefox, download it, and then install the Firebug extension. Among other features, it'll let you click on any component of the page and show you the corresponding location in the source - not just the original page source, but the source after all the Javascript has taken effect.
Actually, if you use Internet Explorer, the IE Developer Toolbar (included in IE 8) does something similar, although I haven't used it much myself.

Resources