Closed sindresorhus closed 3 years ago
Glad to read someone who has the same opinion as me on Twitter URL and UTMs 😊
I'll try to make a PR for this. I've done similar work for a chrome extension as well
https://dev.to/paulleclercq/twitter-without-short-links--1cig
Hi @sindresorhus
I would like to add my Mocha tests from my chrome extension to the projects, but I'm not sure how to add them.
Could you show me an example please ?
https://github.com/sindresorhus/refined-twitter/blob/master/test/index.js
test.serial('should remove every t.co URLs with their real URLs', t => {
const tweet = document.querySelector('#testExtension');
tweet.setAttribute('href', 'http://t.co/fdmQ6yXo8G');
tCoUrls();
// Now we check that we do not have http://t.co/fdmQ6yXo8G anymore
t.is(tweet.getAttribute('href'), 'http://www.wake-me-up.co');
});
More in the docs: https://github.com/avajs/ava
function removeUtms(inputUrl) {
var url = new URL(inputUrl)
url.searchParams.forEach(function(value, key) {
if (value.indexOf('utm_') !== -1 || key === 'ref' || key === 'affil' || key === 'zanpid')
url.searchParams.delete(key)
})
return url.toString()
}
This snippet is to clean utm_
etc. I wouldn't however clean ref=producthunt
as many sites give special offers for ProductHunters
@issuehuntfest has funded $60.00 to this issue. See it on IssueHunt
@polomarcus has submitted a pull request. See it on IssueHunt
@sindresorhus has rewarded $54.00 to @sindresorhus. See it on IssueHunt
Closing as this extension is now deprecated.
We should expand the useless
t.co
redirects to the full URL. The full URL is available in the.js-display-url
element.We should also clean away query params like:
utm_source
utm_medium
utm_content
utm_campaign
utm_term
utm_id
ref=producthunt
Suggestions for additional ones are welcome!
IssueHunt Summary
#### [ sindresorhus](https://issuehunt.io/u/sindresorhus) has been rewarded. ### Backers (Total: $60.00) - [ issuehunt](https://issuehunt.io/u/issuehunt) ($60.00) ### Submitted pull Requests - [#161 Expand urls and remove UTMs ](https://issuehunt.io/r/sindresorhus/refined-twitter/pull/161) - [#200 Update readme.md](https://issuehunt.io/r/sindresorhus/refined-twitter/pull/200) --- ### Tips - Checkout the [Issuehunt explorer](https://issuehunt.io/r/sindresorhus/refined-twitter/) to discover more funded issues. - Need some help from other developers? [Add your repositories](https://issuehunt.io/r/new) on IssueHunt to raise funds.