Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: make script working on Chromium #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

kirill9000
Copy link

На самом Хромиуме (собранном без плагина для магазина расширений) скрипт не работал, ругался на неправильный заголовок и let без strict mode. Кнопки из getButton там тоже похоже уже нет. Ну и заодно пускай версию браузера сам определяет. Ах да, с атрибутом download почему-то ссылка не нажимается.

const downloadUriTemplate="https://clients2.google.com/service/update2/crx?response=redirect&prodversion=38.0&x=id%3D$ID$%26installsource%3Dondemand%26uc ";
const downloadUriTemplate="https://clients2.google.com/service/update2/crx?response=redirect&prodversion=$VER$&x=id%3D$ID$%26installsource%3Dondemand%26uc ";
function getBrowserVersion() {
return window.navigator.userAgent.match(/Chrome\/([0-9.]+)/)[1];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will be broken in the browsers other than Chrome. The script is targeted for Firefox users, because chrome users already have the mean to download crxes.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hardcoded version number was kinda strange, but now I understand. Well, fallback could be added for the case if no match was found.

@KOLANICH
Copy link
Member

Thank you for a PR, it is not usable, because it breaks the script working in Firefox (its main target target audience is FF users, because for chrome there are addons doing the same), but I'll try to make it work in other browsers too. And please write in English on GitHub, because GH is an international website and everyone should be able to understand what is going on.

@KOLANICH
Copy link
Member

see 24ada31

@kirill9000
Copy link
Author

Unlike Firefox, there is no div[role=button] in Web Store on Chromium built without Store extension (Inox). That's why I placed button into another element.

@KOLANICH
Copy link
Member

We can detect the correct element either by class name or by its position in DOM tree. It is very unlikely that the button is drawn by the browser, it also may be possible to make the store work by mocking 'chrome.webstorePrivate' (it is the API to install addons, but I haven't managed to find calls for them during page initialization by setting breakpoints on the lines with them, so I don't know why the buttons are not shown).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants