fwenzel / copy-shorturl

A Firefox extension to quickly create a short URL for the current page and copy it to the clipboard.
https://addons.mozilla.org/addon/copy-shorturl
Apache License 2.0
35 stars 15 forks source link

Cover rel=shorturl, rel=shortlink and maybe data attribute #57

Closed fwenzel closed 8 years ago

fwenzel commented 9 years ago

From https://twitter.com/vegos/status/648646007136382976

@fwenzel Copy ShortURL: rel-shorturl rel-shortlink exist both. Reuters has even data-share-short-url="" attribute. Parse for all possible?

fwenzel commented 9 years ago

rel= are fairly standard, so happy to parse those. Reuters data attribute might be Reuters specific, which I don't mind per se but would be the first foray into site-specific options, which I am at least a tiny little bit concerned about.

RealVegOs commented 9 years ago

Thanks for being open for suggestions. It took me a while to notice that there are more short urls than copy-shorturl copies. So I started to look for short urls in the html of pages. Perhaps I'll find even more variants. The Reuters short link attributes are not in the header. I found them in a div element in the body. Many big media have their own shortlinks. I'll take a better look on it and will come back, if I find something else.

It would be great to catch all this genuine short urls, because I do not like url shorteners much. ur1.ca even bans me from time to time as they work with spamhouse blacklist and stupidly block IPs. Works rather reliable with everything from Syria, no matter whether it is related to Assad or to the democratic opposition. Censuring should be the least, url shorteners do. Sorry for that little novel.

fwenzel commented 9 years ago

No you're totally right -- and I'd love to match most short URLs on sites if they can be detected somehow. Special per-site rules aren't out of the question after all -- I could even have a JSON file that the add-on auto updates from the Internet on occasion. Haven't thought about it much. Just maintaining it long term would be complicated.

fwenzel commented 8 years ago

Covering a lot of options now: https://github.com/fwenzel/copy-shorturl/blob/master/src/data/js/find-short-url.js#L1-L4

Site-specifics are out of scope for now, but I am still open to suggestions on important sites (which) and what we might want to do with them specifically.

fwenzel commented 8 years ago

I think I changed my mind. For certain sites it might make total sense to enable arbitrary selectors? NY times, for instance has: <span class="story-short-url"><a href="http://nyti.ms/2cjHxN9">http://nyti.ms/2cjHxN9</a></span></header>

RealVegOs commented 8 years ago

The Guardian has stuff like "shortUrl":"https://gu.com/p/525m7 in the source. - Let users contribute.

fwenzel commented 8 years ago

Thank you for the suggestions! I figure if I make the format straightforward it should be pretty easy to contribute a patch.