Chrome extension - where to put more code - google-chrome-extension

I'm refactoring js plugin for chrome.
Its mostly based on jQuery with q and handlebars libraries.
For now there is 30k lines of code (2k in background page).
Is it better to include more logic in background or in content-scripts?
If for example I move most of functions to background page, and call them through chrome.runtime.sendMessage with callbacks.
Currently there are about 5k messages send between bg and content-scripts in one plugin run and it takes about 2 min.
Will moving help performance or will it crash it?

Related

Wro4j imports not working after some refreshes

So I have a pretty big application with a lot of imports. Third party js libraries and a lot of angular code.
Now I glued them all together with wro4j into two big files that are compressed.
The order in which I did it is correct as the application works as intended. But often times when I press F5 to reload the page, stuff will break. JS console will start throwing errors and some style settings get lost on the page. But at the same time when I look at the source code, everything is still there. Angular tells about missing modules that are all there and the css that is broken... well the correct css is also in one file and correctly loaded into the page source code.
Has anyone experienced something like this? How would you debug this?

Implement paging in a NodeJS repl

How would one go about adding paging to the NodeJS REPL? I'm building a simple command line app in NodeJS and want to be able to page through output (similar to how the MySQL console lets you page through query results) using less or more as filter programs.
I don't necessarily need the search functionality: just the pausing of the scroll (so I don't have to scroll up to see what's happened) and the ability to cancel the output (so I can quit the output on page 2 of 2000).

Embed Qt window into firefox, via plugin, on Linux

So this is a trivial example of what I'm trying to accomplish:
Using QX11EmbedContainer, and QX11EmbedWidget, I can create two separate apps that embed the widget from one into the window of the other (container <- widget). I would like to do the same in Firefox, and embed the widget into a plugin.
So I created a basic plugin that just contains the QX11EmbedContainer (starting from the 'trivial' example of qtbrowserplugin), and just for testing purposes, another generic widget.
The result is that the generic widget shows inside the plugin just fine, but the container widget 'pops' out to a separate window.
This occurs under Firefox, Chrome, and even Konqueror.
So the question is - Is it possible to embed external Qt widgets into a plugin?
The answer is yes, but the Qt code is buggy, which is why I'm not including it- you wouldn't want it anyway. Managed (with the help of Trolltech engineers) to insert a vanilla QTextEdit widget. Upon attempting to enter text, the plugin would crash, often taking Firefox with it. So clearly, embedding Qt objects directly into a plugin is a no-go.
I also tried launching it separately with mozplugger, but that had it's own issues - mainly focus was not tracked correctly, and would often be lost, requiring you to restart the plugin to get it back.

Writing a plugin using NPAPI + D3D. It works on Firefox, but the browser blacks out. Why?

I'm writing a plugin, using NPAPI and D3D. I just simply put a D3D sample from DXSDK and NPAPI together. I receive a HWND when the plugin starts up, and I passed it to D3D to draw.
It works though. the control(a 400 * 300 rectangle) on the test page DOES show what I expected.
But all other area in FireFox window is black, including the menu bar. All other contents on the test page cannot be seen.
I tried just InitDevice(D3D) with the HWND and do NO rendering at all. But still got the same problem.
Can anyone help me out here plz?
I've seen this happen a few times before; there are two different situations where I encountered it. The first is when I had something weird with my D3D initialization which aparently conflicted with firefox -- but I'm still not sure what I changed to get it working.
The second, which I hope is what you are encountering, is when I was initializing D3D and attempting to draw on the main thread. My theory (unproven) is that Firefox is actually creating its own DX context of some sort and so creating another one on the same thread conflicts. When we moved the init and drawing code to another thread it all started working.
This is one reason that FireBreath has so much code to help make things threadsafe and allow cross-thread calls back to javascript -- every time I've tried to do drawing on the main thread with OGL or DX I've run into problems somewhere.
Hope that helps!

Any browser plugins for customizing web pages intelligently?

I generally use firebug to remove unwanted divs and tags and resize stuff on the web-page .. frequently for gaming sites like chessbomb. But this is tedious, and every time tab reloads, i would have to do it all over again.
So is there any plugin which would remember the setting for particular site and apply it on the load itself. For starters i just need something to remove div tags based on names. If it can resize too then thats all the more useful.
Thanks.
You can use Adblock Plus with some CSS selector usage to do this. Look at the doc related to this here.
For example, you could probably use something like
domain.com##div.class
to hide those divs.
This is a use case for the greasemonkey firefox plugin. You'll need to know a little javascript, but if you're doing these sorts of things in Firebug, I would assume you won't find greasemonkey too dofficult.
Have a look at http://www.greasespot.net/ and http://userscripts.org/ and you may even find someone has already written the script you're after.
To quote wikipedia on Greasemonkey:
Greasemonkey is a Mozilla Firefox extension that allows users to install scripts that make on-the-fly changes to HTML web page content on the DOMContentLoaded event, which happens immediately after it is loaded in the browser (also known as augmented browsing).
As Greasemonkey scripts are persistent, the changes made to the web pages are executed every time the page is opened, making them effectively permanent for the user running the script.

Resources