[Ext] Auto Plain Text Links

Announce and Discuss the Latest Theme and Extension Releases.
Post Reply
AlexVallat
Posts: 90
Joined: September 30th, 2006, 8:53 am

[Ext] Auto Plain Text Links

Post by AlexVallat »

I wanted to get this out there before AMO stops accepting unrestricted addons in April - modifying Firefox behaviour like this can't be done as a WebExtension.

This addon enhances Firefox's native Open Plain Text Links behaviour to work automatically for simple http and ftp links. Firefox can already open plain text links if you fully select them first, but that's a bit of a pain to do. With this addon installed you just need to right click on one and it will give you the normal link opening menu items just as if you had selected it first.

Less easily-recognizable links (for example, missing the http:// scheme prefix) can still be opened by selecting them first; the standard Firefox behaviour.

https://addons.mozilla.org/en-GB/firefo ... ext-links/

This has been delisted by Mozilla, and is now available as a UserChromeJS script from https://github.com/xiaoxiaoflood/firefo ... js-scripts
(autoPlainTextLinks.zip). Installation instructions: https://github.com/xiaoxiaoflood/firefo ... structions
Last edited by AlexVallat on October 19th, 2020, 11:21 am, edited 1 time in total.
grahamperrin
Posts: 82
Joined: July 19th, 2009, 3:56 pm

Re: [Ext] Auto Plain Text Links

Post by grahamperrin »

Version 0.4 tested with Waterfox 56.0.3_4 on FreeBSD-CURRENT.

In isolation, the extension works.

With my everyday profile, which has around eighty extensions, Auto Plain Text Links does not work. The http:// URL in line 23 of https://pastebin.com/sd0fVJHW for example.

I don't see anything relevant in the browser console or web console when I right-click the plain text.

If it's an extension conflict: is there any way to identify the issue without disabling other extensions?
AlexVallat
Posts: 90
Joined: September 30th, 2006, 8:53 am

Re: [Ext] Auto Plain Text Links

Post by AlexVallat »

It sounds most likely a conflict with another extension which has modified BrowserUtils.getSelectionDetails in an un-cooperative way. You may be able to obtain a clue as to which extension that is by going to the Browser Content Toolbox (note, not the Browser Toolbox) and entering:

Code: Select all

Components.utils.import("resource://gre/modules/BrowserUtils.jsm").BrowserUtils.getSelectionDetails.toSource()
If AutoPlainTextLinks is not installed, it should start:

Code: Select all

getSelectionDetails(topWindow, aCharLen) {
    // selections of more than 150 characters aren't useful
    const kMaxSelectionLen = 150;
    const charLen = Math.min(aCharLen || kMaxSelectionLen, kMaxSelectionLen);
...
If it is installed, it will be:

Code: Select all

(function() {
        let onBeforeResult = null;
        if (onBeforeFunction) {
            onBeforeResult = onBeforeFunction.apply(this, arguments);
        }
        let originalResult = replacementFunction.originalFunction.apply(this, arguments);
        if (onAfterFunction) {
            return onAfterFunction.call(this, onBeforeResult, arguments, originalResult);
        } else {
            return originalResult;
        }
    })
If it's anything else, then it's been modified by a different extension.

Alex
grahamperrin
Posts: 82
Joined: July 19th, 2009, 3:56 pm

Re: [Ext] Auto Plain Text Links

Post by grahamperrin »

Thanks,

https://developer.mozilla.org/Firefox/M ... me_scripts

> The Browser Content Toolbox is only available if you're running Firefox in multiprocess mode.

– I have a number of extensions that are not compatible with multi-process, so I might look into this at a later date.
AlexVallat
Posts: 90
Joined: September 30th, 2006, 8:53 am

Re: [Ext] Auto Plain Text Links

Post by AlexVallat »

If you have multiprocess disabled then you can just paste the command into the Browser Toolbox instead of the Browser Content Toolbox. This wouldn't work with multiprocess (as it would give you the result for the chrome process, not the content process) but if you've only got one process then they are one and the same, so it's fine.
grahamperrin
Posts: 82
Joined: July 19th, 2009, 3:56 pm

Re: [Ext] Auto Plain Text Links

Post by grahamperrin »

I get:

TypeError: Components.utils is undefined [Learn More]
AlexVallat
Posts: 90
Joined: September 30th, 2006, 8:53 am

Re: [Ext] Auto Plain Text Links

Post by AlexVallat »

Thanks for the notification. I've uploaded v0.7 which restores compatibility with Nightly 61, keep an eye out for it passing review.
DN123ABC
Posts: 695
Joined: January 9th, 2017, 10:10 am

Re: [Ext] Auto Plain Text Links

Post by DN123ABC »

Is this supposed to be the same as this good one:

http://mozilla.durys.net/textplain/

It would be nice to have that back again.
AlexVallat
Posts: 90
Joined: September 30th, 2006, 8:53 am

Re: [Ext] Auto Plain Text Links

Post by AlexVallat »

It doesn't work in quite the same way as TextPlain, but provides similar functionality for links. It doesn't have any special support for email addresses like TextPlain did, though.

The way it works is to have Firefox provide the same menu commands that would have been present if you had manually selected the entire plain text link before right-clicking. At present, these are:
  • Open Link
  • Open Link in New Tab
  • Open Link in New Window
  • Open Link in New Private Window
  • Bookmark This Link
  • Save Link As
Those are subject to change at any time - until recently there was also the ability to open in a new container, for example. Because it is integrated with Firefox rather than providing its own duplicate commands, the commands available will always reflect the current functionality made available by Firefox.
grahamperrin
Posts: 82
Joined: July 19th, 2009, 3:56 pm

Re: [Ext] Auto Plain Text Links

Post by grahamperrin »

0.7 seems to work – many thanks – with Waterfox 56.1.0_2 on FreeBSD-CURRENT.

Tested with the two URLs at the foot of comment https://github.com/MrAlex94/Waterfox/is ... -377002707
grahamperrin
Posts: 82
Joined: July 19th, 2009, 3:56 pm

caa: and about: URLs

Post by grahamperrin »

Please consider adding support for one or both of these:

caa:

about:

Examples
Background

https://github.com/JustOff/ca-archive – the Classic Add-ons Archive extension for legacy add-ons; https://blog.waterfoxproject.org/waterf ... e-download looks forward to integration with Waterfox.
AlexVallat
Posts: 90
Joined: September 30th, 2006, 8:53 am

Re: [Ext] Auto Plain Text Links

Post by AlexVallat »

AutoPlainTextLinks won't make a URL out of something that Firefox (or Waterfox) wouldn't ordinarily treat as one when manually selected. If you try select it manually and then right click, then if you don't get the "Open Link" context menu items, AutoPlainTextLinks wouldn't be able to add them.
grahamperrin
Posts: 82
Joined: July 19th, 2009, 3:56 pm

Re: [Ext] Auto Plain Text Links

Post by grahamperrin »

OK, thanks.

As a side note, whilst neither type of URL is recognised (by Waterfox) as a link, an about: URL e.g.

about:config?filter=general.useragent.override.addons.mozilla.org

is recognised as a link by Link Properties Plus (but can not be followed).
AlexVallat
Posts: 90
Joined: September 30th, 2006, 8:53 am

Re: [Ext] Auto Plain Text Links

Post by AlexVallat »

Auto Plain Text Links has a new home! Mozilla have delisted it from AMO, so I've redone it as a UserChromeJS user-script, using xiaxioflood's UserChromeJS system.

It is listed at https://github.com/xiaoxiaoflood/firefo ... js-scripts
(autoPlainTextLinks.zip). Installation instructions: https://github.com/xiaoxiaoflood/firefo ... structions
Post Reply