phaistonian / MyExtensions

Are you an extensions developer? Keep track of your Chrome extensions. Be notified for new comments, ratings and more!
https://chrome.google.com/webstore/detail/igejgfmbjjjjplnnlgnbejpkpdajkblm
52 stars 24 forks source link

Adding extensions not possible #6

Closed izzy closed 12 years ago

izzy commented 12 years ago

When I try to add an extension, it always gives me back

"Extension id seems to be invalid ;("

There is no further information in the JS console whatsoever.

Tried with several ids from the webstore - maybe it is caused by the recent change of the webstore(new layout,etc)!?

neocotic commented 12 years ago

I think you might be right with the last point. Extensions which I have added prior to yesterday's web store update are no longer updating. This will probably require some work inspecting the XHR requests now used (if any).

It seems Comments are no longer valid as they are now considered Reviews and users can only submit one (or so it seems).

Also, as of Chrome 15 the Extensions link should probably be changed to the new URL: chrome://settings/extensionSettings (found in Chrome's Options). The original URL (chrome://extensions) still works but it's probably best to just update this.

neocotic commented 12 years ago

I did some debugging and found that the problems adding and updating extensions are linked and seem to stem from the same line of code;

js.js:1417

var matches = responseText.match(/<img class="detail-logo-[^"]*" src="([^"]*)" alt="Logo">[\s\S]*<div class="detail-title">([^<]*)<\/div>([^<]*)<[\s\S]*<div class="detail-num-users">([^<]*) users<[\s\S]*Version: <\/b>([^<]*)<[\s\S]*<span id='detail-update-date'>([^<]*)<[\s\S]*users<br>([^<]*) weekly installs</i);

The RegExp no longer matches anything in responseText really as the DOM structure and ordering has changed along with class names when the web store was updated.

neocotic commented 12 years ago

I had some time and wanted to play around with regex so I think this is a good fix;

var matches = responseText.match(/<img class="detail-dialog-icon[^"]*" alt="Extension" src="([^"]*)"[^>]*>[^<]*<[\s\S]*<h1 class="detail-dialog-title">([^<]*)<\/h1>[^<]*<[\s\S]*(?:<span class="detail-dialog-from[^"]*"[^>]*>(?:[^<]*<a[^>]*>([^<]*)<\/a>|from(?:&nbsp;)*([^<]*))<\/span>|<div class="detail-dialog-from[^"]*"[^>]*>Verified author: ([^<]*)<\/div>)[^<]*<[\s\S]*<span class="detail-dialog-users"[^>]*>([^<]*) users<\/span>[^<]*<[\s\S]*<div class="overview-tab-right-bar-summary"[^>]*>([^<]*)<\/div>/i);

You may have noticed that weekly installs and version are no longer matched. Unfortunately, I see no way of getting the version as it is on the Details tab which is not rendered in the response. However, the concept of weekly installs appears to have been dropped entirely (which I'm really happy about).

The matches variable now has the following important elements;

  1. Image
  2. Title
  3. Author (from link)
  4. Author (from plain text)
  5. Author (Verified author: domain)
  6. Users
  7. Summary description (although not currently used I thought I'd match it while I was doing this - feel free to remove)

My regex skills aren't great and you may be able to merge Author in to a single match; otherwise a simple OR would suffice. Obviously this is only some the work required and js.js will need updated to reference the correct indices. Also, any reference to the version and/or weekly installs will need to be removed unless an alternative method of determining either can be found.

neocotic commented 12 years ago

I've opened a pull request for this which includes a quick fix for this problem. However, I suggest that the code relating to version and weekly installs information are cleaned afterwards.

neocotic commented 12 years ago

@mkzero It appears the extension on Chrome Web Store has already been updated with the fix I provided. Can you confirm that you no longer see this problem so this issue can be closed off?

izzy commented 12 years ago

Okay, works just fine now, closing this.