Your solution would probably end up being treated as malware
From your description, it appears that you want to create a JavaScript library that a website can include on their pages that will guarantee their compliance with the "cookie law".
Let's side-step the technical issues surrounding the actual implementation of this law when it comes to the location of the user, the client (remote session anyone?), the server and the owner of the web application running on the server. And, let's constrain further and only consider the UK guidance offered around the EU directive.
From the Information Commissioner's Office:
Cookies or similar devices must not be used unless the subscriber or
user of the relevant terminal equipment:
(a) is provided with clear and comprehensive information about the
purposes of the storage of, or access to, that information; and
(b) has given his or her consent.
This implies that your widget will have to act as the clearing house for this user consent. If you do not have control over the server code then your software will have to block the cookies emanating from the server until such consent is obtained. This means that your software will be interfering with third-party libraries (your Google Analytics and Facebook Likes etc).
Such interference, no matter how well-meant, is very likely to degrade the user experience and be looked upon extremely unfavourably by the owners of the third-party libraries. Thus it will be treated as malware.
I would think again before going down this road.