diegocr / CleanLinks

Converts obfuscated/nested links to genuine clean links.
164 stars 45 forks source link

compatibility issue with WordPress back-end #128

Open atomGit opened 8 years ago

atomGit commented 8 years ago

WP 4.5.2 Fx 46.0.1 CL 2.7.1 Linux Mint 17.3, KDE

when editing a post/page in the WP back-end, clicking on a link should do nothing more than pop-up a link editing tool, however if the link being clicked is parsed by CL, the link instead opens in the same tab and all editing changes are lost - this is in event delegation mode

as i understand it from a previous post, event delegation mode is the preferred method of using CL because the code for the other mode is old and not updated, however, personally, i would much prefer to use the 'live' mode where the links are parsed and highlighted upon page load

diegocr commented 8 years ago

DOM traversal is indeed outdated/unmaintained, and might causes websites to load slower (since at page load we have to transverse all page's elements looking for links, to clean them up), but if that works better for you it's fine, your decision :)

As for the WP-backend issue, i would usually whitelist the domain to prevent CL from touching the links.

GitCurious commented 8 years ago

If using Dom Traversal Mode, is the code involved somehow inferior or different to that used for Delegation Mode ?

Is there any technical difference to the end generated links other than that it`s potentially slower ?

(Ideally, I would also prefer to use Dom Traversal to visually see which links are cleaned before clicking)

atomGit commented 8 years ago

i'm just a hobbyist developer, so with that in mind, i don't understand why DOM traversal mode would slow page load at all - CL doesn't need to respond instantly and style/rewrite links as the page is loaded in real time - if there's a few hundred ms delay, i would think that would be perfectly acceptable by the majority of users

without knowing anything about the Fx API, as a developer i would be waiting for the page load to complete, after which i'd use a RegEx to look for the links and then rewrite and style them

regarding my WP issue, i like to keep CL enabled rather than whitelist my site because i want to see what links contain unnecessary tracking code so i can edit them

regardless, CL should not be altering the default behavior of the WP editor by opening links instead of displaying the link edit pop-up - this is a bug, plain and simple, so far as i'm concerned

diegocr commented 8 years ago

CL in DOM traversal mode does start cleaning links as soon the page is loaded (by listening to DOMContentLoaded), the problem with this mode is mainly with huge pages, with tons of elements/links, which could freeze the browser while it's processing them.

Such a freeze could still happen even if we use some delay, so i'm afraid that won't help. There could also be issues with sites dynamically injecting the content (through XMLHttpRequest - aka ajax - calls), plus In DOM traversal we also have to check for any iframes in the document, and traverse them as well.

So, Event Delegation mode was introduced to quickly workaround/fix these potential issues, by just listening to click events on the document. Of course using this mode you will lose the ability to highlight all cleaned links around the page, as pointed in the AMO page's description, so for users who like this the most and don't usually load huge sites (nor found any issue related to traversal) it's fine to stick using that mode i suppose :)

Re WP issue, instead of whitelisting the whole domain, you can also insert a part of the editor url where you found the problem into the "Skip links matching with" option.

atomGit commented 8 years ago

Re WP issue, instead of whitelisting the whole domain, you can also insert a part of the editor url where you found the problem into the "Skip links matching with" option.

the problem with that, when DOM traversal mode is disabled, is that links that i would like to edit because they are redirects, or whatever, will not be highlighted, therefore it's not so convenient to detect them