> This page is consuming a lot of resources, do you want to keep executing JavaScript on this page?
> Stop / Allow only this time / Allow always
On the other hand if you set it too high then those websites will aim for that limit to maximize profit without triggering the warning. You'll still waste a ton of resources and you've only mitigated the issue somewhat.
I'm not saying it's impossible, just that "just add a dialog when CPU usage is high" might be a bit naive. There's a subtle balance to these things.
I'm not going to file patent for this, thanks in the code will be enough. Enjoy :)
As an alternative, you could do a survey at install time - check if a battery is present, get power profiles, run your benchmark js stuff, check CPU, RAM, disk type (HDD/SSD) - then download profiles for that/those configuration(s). Then put a 'sensitivity' slider in the advanced options to allow power users to tweak/turn off the limit.
No need to send me code. Cash will do fine.
Of course, they could start asking for permission before letting a site use more than X CPU, or before letting the site execute JavaScript at all, but most people don't want additional popups like that.
Someone said that Firefox warns you when a site uses a lot of CPU but I couldn't trigger that warning (maybe I didn't run it long enough or the feature is in a newer version).
They allow it because the point of scripts is to consume some level of CPU resources, and setting an arbitrary limit on how much is too much is bound to cause a bad user experience when e.g. rendering large visualizations or playing a fast-paced game.