sindresorhus / refined-twitter

Browser extension that simplifies the Twitter interface and adds useful features
MIT License
1.31k stars 89 forks source link

Expand `t.co` URLs and cleanup #21

Closed sindresorhus closed 3 years ago

sindresorhus commented 6 years ago

Issuehunt badges

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:

Suggestions for additional ones are welcome!


IssueHunt Summary #### [sindresorhus sindresorhus](https://issuehunt.io/u/sindresorhus) has been rewarded. ### Backers (Total: $60.00) - [issuehunt 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.
fregante commented 6 years ago

https://github.com/bevacqua/ftco

polomarcus commented 6 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

polomarcus commented 6 years ago

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

sindresorhus commented 6 years ago
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

kurtextrem commented 6 years ago
    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

IssueHuntBot commented 5 years ago

@issuehuntfest has funded $60.00 to this issue. See it on IssueHunt

IssueHuntBot commented 5 years ago

@polomarcus has submitted a pull request. See it on IssueHunt

issuehunt-oss[bot] commented 3 years ago

@sindresorhus has rewarded $54.00 to @sindresorhus. See it on IssueHunt

sindresorhus commented 3 years ago

Closing as this extension is now deprecated.