openstyles / stylus

Stylus - Userstyles Manager
https://add0n.com/stylus.html
GNU General Public License v3.0
5.5k stars 306 forks source link

The behavior of usercss installation page #348

Closed eight04 closed 6 years ago

eight04 commented 6 years ago

This is not related to OUCSS.

Example URL: https://raw.githubusercontent.com/RaitaroH/YouTube-DeepDark/master/YouTubeDeepDarkMaterial.user.css

IIRC, when #134 is implemented:

Current behavior:

In the new version, the source code page is left in the window/tab, which is caused by https://github.com/openstyles/stylus/commit/aedb02bbb19356fe069996c3d21577a88ed5cf20#diff-e0e82cc2f07995a5e5771a1cf2a8a8c1R190.

-      port.postMessage({method: 'closeTab'});
+      chrome.runtime.sendMessage({method: 'closeTab'});

I think it is an accident because port.postMessage({method: 'closeTab'}) closes the source code tab but chrome.runtime.sendMessage({method: 'closeTab'}); closes the installation tab, and the closeTab handler in content/install-hook-usercss.js is not removed.

Also, in the current version, the installation tab is not closed after closing the source code tab.

tophf commented 6 years ago

It's not an accident. Like I said, it's working as intended. The reason is to preserve user navigation. I can understand why you implemented history back/closing of the source tab, but I think the old behavior was wrong: if a user navigation was performed by the browser and the page was actually shown, we should not navigate back nor close it. AFAIK Chrome Webstore even has a policy about extensions that behave this way.

Ideally, we should have used webRequest API to redirect the URL to our installer page like Tampermonkey does, but I don't want to add a new permission just for this purpose.

eight04 commented 6 years ago

If it is not an accident, the closeTab handler should be removed.

in the current version, the installation tab is not closed after closing the source code tab.

This might be a bug in Firefox. I can't reproduce it in Chrome.