Mte90/Share-Backported

Auto close the window for Reddit

Mte90 opened this issue · 12 comments

Mte90 commented

Right now we are doing this for FB, TW and Linkedin because it is easy (the url changes) so we can do also that for Reddit.

Hi, Can you share, how to set up project?

Mte90 commented

Right now we are doing this for FB, TW and Linkedin because it is easy (the url changes) so we can do also that for Reddit.

Can you share commit which you are doing on your code FB , Twitter, I need more information about this story ^^

Mte90 commented

This is the line https://github.com/Mte90/Share-Backported/blob/master/background.js#L24
As I can see the reddit support is here but is not working anymore.

Basically the extension open a window and with a browser method if the url changes we do a check if the final page of a service, to avoid redirects and this kind of things.

(@Mte90 If you hit y on a code page, GitHub will update the URL to a canonical/stable one. As an added bonus, we would see the referenced code here.
More goodies behind ?)

#158 is getting us 80% there.

const closeWhen = [
'dialog/close_window',
'latest_status_id='
];

needs an update with the part of the URL, that indicates a successful share.
Therefore, inspect from about:debugging the modalUrl from

const modalUrl = tabinfo.url;

Mte90 commented

I did some testing, Reddit on selecting the sub to share change the url and again after posting with urls like this:

So I merged the new code but I think that we need regex support to be able to detect urls like: https://www.reddit.com/*/*/comments/*/* with * I mean everything there.

Instead of RegExp (see https://xkcd.com/1171/ ), can it be defined as pair of hostname and path contains comments (or another keyword)?

Mte90 commented

Well if contain comments can be fake positives detection, for that reason I would prefer a regex.

Hm, what about split on / and check for third position?
I'm really trying to avoid RegEx if possible.

Mte90 commented

Well if we do in that way is more easy with a regex, we can have other services that use other symbols.

🤷 Do as you please.