If you can't leave a comment, but really want, you can

Yes, it is the same problem I encountered when visiting another Landing page that sold me a supposedly first class product. But after a visit of the courier, you know that you lit, and leave a review, or otherwise to warn the others you're not. At this point in the head and got the idea of the browser extension that would allow to leave comments, notes, feedback, or to read other people's, right on the visited website.



The name of all that CommentAll. If still interesting — I ask under kat. Even if not interested, still look under the cat may be too early to draw conclusions, and write your angry comment is always welcome.


I'm just a gift to the wife stumbled on a site that sells night projector, projecting onto the ceiling a starry galaxy. I was in shock — his presentation on the website he bought me. Returning to the site after he was dead that he brought a courier and finding similarities with what is advertised on the website, I saw only static comments and the form that sends my review nowhere.

Participate could only mocking the poll, here it is:
• We are delighted, now sleep like in a fairy tale
• An original gift, thank you!
• Well that operate around the clock
• Must buy!
• Ordered, satisfied, thank you very much

In the end, it all touched me, and there goal is not so easy to leave. The idea of the expansion of Commentall is to provide an opportunity for the Internet audience to communicate directly to sites anywhere without crossing, to warn other Internet users about the possible location of the threat content, sometimes not accurate or even false information, i.e., even where the author himself did not foresee the possibility to comment or felt it was unnecessary.

Instead of a thousand words about the principle of the extension offer to watch a short minute video:



a Little about the technical side of the project


The extension is written for browsers on the WebKit engine, such as Google Chrome( + derivatives Yandex.Browser, Amigo, etc.), under Opera separate release, as Mozilla your extensions, and different from the rest Firefox under everything else yet, under IE I do not know whether.

The main difficulty which had to face – modern browsers do not allow crossdomain requests. Moreover, with respect to most extensions found in the network, techniques such as JSONP, CORS did not act or could not be applied. The decision came from the extension – in browsers on WebKit they consist of the "main" part and the so-called "background'a". And it turns out that all requests that pass in background'e browser passes. Left to tie it all together. Turns out this chain:



I.e. for all requests needed in the form of wrapper functions that accept query parameters in background'e, was formed by the request and the completion CallBack was called. I found the only working the solution from romannurik and slightly modified it (to handle POST requests).

some Background - Xhrproxy.js
var XHR_PROXY_PORT_NAME_ = 'XHRProxy_';
setupXHRProxy function() {
chrome.extension.onConnect.addListener(function(port) {
if (port.name != XHR_PROXY_PORT_NAME_)
return;
port.onMessage.addListener(function(xhrOptions) {
var xhr = new XMLHttpRequest();
xhr.open(xhrOptions.method || "GET", xhrOptions.url, true);
if ( xhrOptions.method=='POST' ) {
xhr.setRequestHeader("Content-type", "application/x-www-form-urlencoded");

xhr.setRequestHeader("Connection", "close");
}
xhr.onreadystatechange = function() {
if (this.readyState == 4) {
port.postMessage({
status: this.status
data: this.responseText,
xhr: xhr,
url: xhrOptions.url
post_data:xhrOptions.params
});
}
}
if ( xhrOptions.method=='POST' ) {
xhr.send(xhrOptions.params);
}else{
xhr.send();
}
});
});
}
function proxyXHR(xhrOptions) {
xhrOptions = xhrOptions || {};
xhrOptions.onComplete = xhrOptions.onComplete || function(){};
var port = chrome.extension.connect({name: XHR_PROXY_PORT_NAME_});
port.onMessage.addListener(function(msg) {
xhrOptions.onComplete(msg.status, msg.data, msg.xhr, msg.url, msg.post_data); 
});
port.postMessage(xhrOptions);
}

setupXHRProxy();


an example of calling the extension:
proxyXHR({
method : 'POST',
url : url,
params : post_data,
onComplete : CommentAll.loadComment
}); 


and in the manifest file.json
 "background": {
"scripts": ["includes/xhrproxy.js"]
}


If anyone has better solution I will be glad to listen adequate criticism is welcome. If the topic is developing extensions interesting, I'll write a sequel.

PS


For ease of commenting embedded social authorization for Vkontakte, Facebook and Twitter. But comments can be left anonymously. Yes, there are certainly a small limitation due to the small audience while the extension – comments and notes will be visible only to those who have also is expanding. In the future, it is planned to expand the functionality of the extension (pardon the tautology), but in fact he has now opened other possibilities.

Here's just a sample applications:
• When viewing the ads (e.g., the sale of the car or apartment), leaving a note after the call or inspection of the object (or see an existing opinion)
• When two or more persons on the same content, editing or discussing it in place to avoid confusion.
• When it is necessary not to advertise the fact of correspondence, communicating at the same time on not popular websites.
• Use for quests, revelations, and maybe something else.
I wanted to add only that in the extension there is no advertising or other monetisation. I almost forgot to warn you, working in-house filter foul language, transforming the words to the synonyms, and sometimes antonyms.

And exclusively for those who read the article from the beginning this exceptional survey.
Article based on information from habrahabr.ru

Комментарии

Популярные сообщения из этого блога

The release of the new version of the module modLivestreet 0.3.0-rc

mSearch: search + filter for MODX Revolution

Emulator data from GNSS receiver NMEA