theAlinP / twitter-link-deobfuscator

A Firefox add-on that restores the original destination of the links (from tweets) that have been shortened by the Twitter servers. It only runs while browsing Twitter's website (twitter.com).
https://addons.mozilla.org/en-US/firefox/addon/twitter-link-deobfuscator/
MIT License
36 stars 5 forks source link

Error warning that the page structure changes flashes on initial page load #2

Closed muellermartin closed 5 years ago

muellermartin commented 5 years ago

Upon initial loading of the Twitter website, following error message shows for a short time at the lower right corner of the browser viewport:

The Twitter team modified the page structure! "Twitter Link Deobfuscator" no longer works properly.

After about a second, the message disappears. Despite the short visibility of the error, the plugin works as intended.

The error message should only appear, if the plugins really can't process the page structure.

theAlinP commented 5 years ago

That message is meant to appear if Twitter Link Deobfuscator cannot find or doesn' have access to the Twitter Timeline. I saw this behavior when I allowed TLD to run in iframes, while developing it. This is the reason I stopped it from running in iframes (and the fact that in iframes there are no links that it can clean).

Can you tell me what version is your browser and what OS is it running on? Do you think is there anything special about your system that is worth mentioning?

By "initial loading" do you mean the very first time after you installed the extension or after every browser (re)start?

muellermartin commented 5 years ago

Maybe it would be better to indicate this error in the icon, but that would require to have it in the menu bar.

Currently I'm running Firefox 66.0.2 (64-Bit) on macOS 10.13.6.

By initial loading I mean the loading of the website in a tab or window while the browser is already running. If the tab/window gets reloaded, e. g. by clicking the refresh button, then the message does not get shown.

I've created a GIF of the issue: tweet-deobfuscator-error-flashing-bug

theAlinP commented 5 years ago

Hey, Martin

I still can't figure out why that happens.

I tested the add-on on Firefox 60, 64, 65, 66, 67 on Linux and 2 Firefox versions, don't remember which, on Windows, at different points in time but I didn't encounter this bug. I'm sorry, but I don't have a Mac and I can't install OS X or macOS in a virtual machine just to test this add-on.

After I fix the 1st issue I will find another way to display the warning or remove it altogether.

muellermartin commented 5 years ago

Thanks for your investigation efforts. It's really strange that this issue only seems to occur on macOS, but good to know. I will test a few other settings and try to debug why this happens for my installation. If I can help with log files or specific modifications to the source code, feel free to ask and I try to help :)

theAlinP commented 5 years ago

Mozilla upgraded their browsers recently, can you tell me if this is still happening?

muellermartin commented 5 years ago

Unfortunately the updates did not solve the issue. But in the meantime I found out that the issue relates to some setting(s) in my Firefox profile. If I install your add-on in a new profile or Firefox Nightly, the issue is not there. If I find the time, I will try to debug this to pin down the relevant settings causing this issue.

theAlinP commented 5 years ago

The key lines to look out for are from content_script.js:

        const stream = document.querySelector("#stream-items-id") || console.error("The timeline was not found");    // line 171
        //...
        if (stream !== undefined && stream !== null) {    // line 200
          //...
        } else {    // line 231
          //...
        }    // line 254

On line 171 is created a new binding with the list (<ol> element) as its value. Inside this list are created the initial tweets, as <li> elements, and later on, as the user scrolls down, are appended new tweets. If the list is not found, an error message is logged to the console.

On line 200 is checked if the binding stream was created successfully (on line 171). The way I know to do that is by checking that it is neither undefined nor null. If it was created successfully, in the block from line 200 to 231 is created a Mutation Observer that watches for changes to the stream variable, like the addition of children, meaning tweets, then calls the function revealLinks() to clean them.

If the binding was not created successfully, meaning that the list was not found, in the block from 231 to 254 is created then shown the warning message.

If the message was shown, it means that the first block was not executed. Please verify that by scrolling to the bottom of the page, wait for new tweets to be added and check the new links if they have been cleaned. They shouldn't be deobfuscated because the Mutation Observer was never created and it didn't run revealLinks().

Also, please open the web console or the browser console and look for any error messages. To find them, look for content_script.js to the right of the console. Aside from the messages from lines 171 and 232, what other error messages do you see?

theAlinP commented 5 years ago

Seeing as this issue is due to a broken Firefox profile and not the add-on itself, I think that I can close this issue.

I am going to close it the day after tomorrow. In the meantime, if you have any objections, please let me know.

I will reopen it if I receive any more reports from other users.