-
Notifications
You must be signed in to change notification settings - Fork 90
Conversation
const urls = $('a[data-expanded-url]'); | ||
|
||
for (const el of urls) { | ||
const expandedUrl = el.getAttribute('data-expanded-url'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should use .dataset
@@ -0,0 +1,13 @@ | |||
function removeUTMs(url) { | |||
return url.replace(/[?&#]utm_.*/, ''); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be better to extract use the URL
and URLSearchParams
APIs to handle the query strings properly. Naive replacements like this is fragile.
readme.md
Outdated
@@ -42,6 +42,7 @@ We use Twitter a lot and notice many dumb annoyances we'd like to fix. So here b | |||
- Keyboard shortcut to toggle Night Mode (<kbd>Alt</kbd><kbd>m</kbd>). | |||
- Uses your personal color theme on all profiles. | |||
- Hides the header image on profile pages. | |||
- Expand URLs and remove UTMs. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Needs a better wording than UTMs. Few know what that means.
return url.replace(/[?&#]utm_.*/, ''); | ||
} | ||
|
||
export default function () { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The feature needs to ensure it's only run once. Now it's run on everything for each new tweet.
Why? |
Can't we do the same as you do in https://github.com/polomarcus/faster-links/blob/910eeaf7d78c83d47dbf9116fde143ccf5c77480/app/scripts.babel/contentscript.js#L95 ? |
It uses Linkpeelr from @ibagrak , as he hasn't answered me since 2016 I guess it's OK to use it 😄 ibagrak/linkpeelr#15 Would you be OK to use it @sindresorhus ? About |
Sure. You can use
They do. Try clicking the "Website" button here: https://www.producthunt.com/posts/makerlog-2-0 |
Update✔️ No more shorten links
Next stepIt does not affect twitter card link like this one as there is no |
source/features/expand-urls.js
Outdated
|
||
// Example: https://twitter.com/polomarcus/status/955649699477950464 | ||
async function twitterCardURLs() { | ||
await sleep(2000); //iframes takes longer to load |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Annoying... There is small lag when loading a Tweet card forcing me to use a sleep
😕
Since the last time this PR had activity, Twitter launched their redesign to everyone, so I don't think this PR is functioning anymore... Are you still interested in finishing this and retargeting the new Twitter design or should I close? |
Fixes #21
Features
When
data-expanded-url
attribute is available 2 features are activated :Expand URLs
Replace t.co URLS with
![screenshot from 2019-01-10 19-31-20](https://user-images.githubusercontent.com/4059615/50988941-5a497600-150e-11e9-97fa-f762bd099c13.png)
data-expanded-url
dataTweet with a data-expanded-url
Remove UTMs
Remove UTMs from replaced URLs, leave the UTMs inside
data-expanded-url
though:Tweet with UTMs to test this feature
Limit
It does not remove
ref=producthunt
from linksIt does not affect twitter card link like this one as there is no
![screenshot from 2019-01-10 19-45-22](https://user-images.githubusercontent.com/4059615/50989682-4e5eb380-1510-11e9-8073-f324e9b5f554.png)
data-expanded-url
and we need to have our own link unshorten API