MozillaZine

[Ext] Auto Plain Text Links

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

Post Posted March 26th, 2017, 1:55 am

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/firefox/addon/auto-plain-text-links/

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

Post Posted January 29th, 2018, 3:16 pm

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: 75
Joined: September 30th, 2006, 8:53 am

Post Posted January 30th, 2018, 1:22 am

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: 29
Joined: July 19th, 2009, 3:56 pm

Post Posted January 31st, 2018, 12:16 pm

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: 75
Joined: September 30th, 2006, 8:53 am

Post Posted February 1st, 2018, 1:02 am

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: 29
Joined: July 19th, 2009, 3:56 pm

Post Posted March 27th, 2018, 10:02 am

I get:

TypeError: Components.utils is undefined [Learn More]

AlexVallat
 
Posts: 75
Joined: September 30th, 2006, 8:53 am

Post Posted March 27th, 2018, 10:46 am

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: 395
Joined: January 9th, 2017, 10:10 am

Post Posted March 28th, 2018, 5:54 am

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: 75
Joined: September 30th, 2006, 8:53 am

Post Posted March 28th, 2018, 6:21 am

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: 29
Joined: July 19th, 2009, 3:56 pm

Post Posted April 2nd, 2018, 1:21 pm

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

Return to Extension/Theme Releases


Who is online

Users browsing this forum: No registered users and 1 guest