Twitter share button renders as hypertext link


#1

This happens when certain extensions are enabled. The URL shared by this hypertext is also incorrect as it does not share what I ask it to share (shares current url). Below is what I see in developer tools

GET https://platform.twitter.com/widgets.js net::ERR_BLOCKED_BY_CLIENT

Can I detect this in my code somehow ?


#2

A quick search for “net::ERR_BLOCKED_BY_CLIENT” and JavaScript mention AdBlock clients may block Twitter’s JavaScript.

Adding an Easylist filter list subscription to your ad blocker configuration may block Twitter’s widget JavaScript from loading in your browser.
https://hg.adblockplus.org/easylist/file/10ab31cd7d06/easylist/easylist_specific_block.txt

Adding an exception rule through your ad blocking software’s should allow you to override the choices made by your subscribed, auto-updating filter list. Examples for Adblock Plus:
https://adblockplus.org/en/filters#whitelist
https://adblockplus.org/en/filter-cheatsheet#exceptions2

Based on those documents the following additional filter should allow platform.twitter.com content:
@@||platform.twitter.com^

You may attach an event to the script element or the resource loader on your page to detect when Twitter’s widgets JavaScript has loaded or has failed to load within your expected timeframe.
https://html.spec.whatwg.org/multipage/indices.html#event-load

If your webpage uses JavaScript factory functions you may want to insert your own fallback content or message in the expected render area if the JavaScript fails to load.

Note: Twitter’s JavaScript may fail to load for reasons similar to an ad blocker such as an entire country blocking access to Twitter.


#3

How can I detect whether Twitter’s widgets js has loaded or not ? What will be the best indicator ? I am unable to pin point a particular event which when fired tells widgets js has loaded.


#4

You may record when Twitter’s widgets JavaScript has cleared the twttr.ready asynchronous JavaScript function queue by passing your callback to twttr.ready().
https://dev.twitter.com/web/javascript/events

You can attach events to the script element you use on the page to track the load event on the resource or other customizations for your specific use.


#5