ANOLE 1.1.0 ― Chrome Extension to Transform Selected Text

in #utopian-io6 years ago

Anole is an open source productivity extension for Google Chrome. This extension makes all sorts of string transformations easier. Simply right click a text selection on any web page, choose your desired transformation (e.g. camelCase) and the reformatted text is placed on the clipboard ready to paste.

anole-tile-440x280.png

Anole is available in the Chrome web store as a free extension. Or if you want to hack on it, install the unpacked extension in developer mode directly from the github repo. Instructions for both methods are in the README.md.

Note that one advantage of installing the packed release from the web store is receipt of automatic updates.

Currently Anole can convert any selected string into CamelCase, kebab-case, Start Case, snake_case, and more. The list of cases and formats will be growing and new features for additional flexibility (e.g. transform templates) will be added. The main feature added in this release, granting user more control over Anole's right-click context menu, is important to support this future flexibility.

Anole context menus in action

Anole adds each potential text transformation to the browser's context menu. The plan is to add a sizable collection of these stock transformations. This could have resulted in a context menu becoming quite cluttered or complex to navigate. To continue adding features, it was essential to allow the user to choose which features to include or exclude from the context menu.

anole-options-menu.png

Repository

https://github.com/tdreid/anole

About Anole ― The Browser extension that transforms selected text onto your clipboard

Anole was originally born to fill a simple need. Every day, several times a day, at work I found myself creating new git branches. Our convention at this workplace was to name branches after the title of the task worked on―only without spaces or special characters.

So given a task in the web based task list:
#101: Fix the Foo so that it Bars Steel instead of Iron

I would create a branch called:
101-fix-the-foo-so-that-it-bars-steel-instead-of-iron

This was tedious. There were websites where I could paste the task name, click a button, and then cut and paste transformed text into my git client. Too many clicks. I wanted to paste immeidately after copying. I realized, since these tasks were already listed on a web page, that a Chrome extension could do this job for me.

That's what Anole does. Select some text in a web page. Then choose one of several formats to transform that text directly onto the clipboard. Paste it wherever you like.

Anole at work

As the extension took shape it became clear that throughout a workday I did a lot of cutting and pasting of text. Moreover many of those pastes, like naming a variable to represent data described in a specification, could benefit from various forms of string play. As I tinkered with the early versions it seemed like I discovered a new use for this handy shortcut daily.

Pronounce The Name

If you're wondering exactly how to pronounce, A-n-o-l-e, the name of this handy little extension I wrote an earlier article about exactly that. Or just take this hint― "An Oh Lee ."

Either way an Anole is a smallish lizard that can change its color from green to brown and back. This camouflage is very useful for its life in the leaves and on the trunks of trees. Just as it's hoped that this tiny extension's ability to transform text will be handy to you for changing between cases of text.

An Anole
The American Anole has an interesting ability to change its shade of green or brown — just like the Anole browser extension changes text to suit your needs. Image by Erwan Hesry on Unsplash

Technology Stack

Anole is a Chrome browser extension and so comprised of pure JavaScript, CSS and some HTML. The Chrome Extension API of course plays an important role in how that's all tied together. Skeleton.css provided the foundation for the style of the options page.

To provide a pipeline for transpiling, bundling and minifying the packed extension for the Chrome web store browserify.js, babelify,js, and uglify.js are used. These are all dev dependencies.

Note that a release of the nested dependency cached-path-relative of 1.0.2 or greater should always be specified to mitigate a known vulnerability in earlier versions of the module.

Conventions for transforming from one case to another may have slight variations. For example, some may hold that camel cased text should or shouldn't start with a capital letter (i.e. CamelCase vs. camelCase.) Moreover, there are controversies over the preferred way to write title case. To resolve such idiosyncrasies I took the transformations from Lodash as a canonical starting point.

Thus, Lodash is a final dev dependency, though only a few cherry picked string functions are bundled with the packed extension.

Roadmap

As mentioned above there are many (endless?) variations on the conventional manipulations of text that come in handy. Now that the context menu can be customized to each user's preference the next step will be to include every imaginable transformation. Some examples:

  • Copy a selection in one language into another language
  • Copy JavaScript code snippets into prettified JavaScript
  • Copy inline SQL into indented and formatted SQL
  • Please suggest more =) at https://github.com/tdreid/anole/issues.

Ultimately I would also like to provide a feature allowing custom transformation templates.

Contribution Guidelines

Anole is open source, licensed under GPL-3.0 (only). To contribute please make a pull request on github.

Bug reports as well as suggestions for new text transformations are welcome here

Recently Added [ver. 1.1.0]

Anole 1.0.3 has been available in the Chrome web store since last summer. Although there were many transformations that I've wanted to add I've hesitated because of one factor―what is a useful feature for one user may be clutter for another. Since the extension updates automatically it could have been annoying for someone using only one or two of the transformations to then have to find those in a longer list.

So, Anole 1.1.0 adds the ability to select only those menu items that one wishes to use, hiding the rest. This was done by adding an options page to the extension. Selected options are saved using chrome.storage.sync so that a change made on one device will take affect across all of a signed in user's devices.

// in options.js
chrome.storage.sync.set(
    {
      copyToCamelCase: document.getElementById('copyToCamelCase').checked,
      'copy-to-kebab-case': document.getElementById('copy-to-kebab-case')
        .checked,
      'copy to lower case': document.getElementById('copy to lower case')
        .checked,
      copy_to_snake_case: document.getElementById('copy_to_snake_case').checked,
      'Copy To Start Case': document.getElementById('Copy To Start Case')
        .checked,
      'COPY TO UPPER CASE': document.getElementById('COPY TO UPPER CASE')
        .checked
    }, ...);

...

// in anole.js

cases.forEach(c => {
  chrome.storage.sync.get(null, storedSettings => {
    if (storedSettings[c] || storedSettings[c] === undefined) {
      chrome.contextMenus.create({
        title: c,
        id: c,
        contexts: ['selection'],
        onclick: copyTransformation
      });
    }
  });
});

GitHub Account

https://github.com/tdreid
@tdre on the Steem blockchain

Sort:  

Thank you for your contribution. Though seems like a nice little update to the extension, I am not sure if people use this type of copying, I might be wrong though.

Doesn't if (storedSettings[c]) will take care of undefined too?

Your contribution has been evaluated according to Utopian policies and guidelines, as well as a predefined set of questions pertaining to the category.

To view those questions and the relevant answers related to your post, click here.


Need help? Write a ticket on https://support.utopian.io/.
Chat with us on Discord.
[utopian-moderator]

Thanks for your review @codingdefined. I'm sure you're correct about if (storedSettings[c]). That was a sanity check while debugging and I meant to remove it.

As for the level of interest, time will tell =) I know it's useful to me and a couple of colleagues.

I appreciate your feedback.

Thank you for your review, @codingdefined! Keep up the good work!

Calling @originalworks :)
img credz: pixabay.com
Nice, you got a 84.11% @minnowbooster upgoat, thanks to @tdre
BuildTeam wishes everyone a great Christmas and bullish Holidays
Want a boost? Minnowbooster's got your back!

Fa La La LOL. Happy Christmas BuildTeam! @minnowbooster =)

Congratulations! This post has been upvoted from the communal account, @minnowsupport, by tdre from the Minnow Support Project. It's a witness project run by aggroed, ausbitbank, teamsteem, someguy123, neoxian, followbtcnews, and netuoso. The goal is to help Steemit grow by supporting Minnows. Please find us at the Peace, Abundance, and Liberty Network (PALnet) Discord Channel. It's a completely public and open space to all members of the Steemit community who voluntarily choose to be there.

If you would like to delegate to the Minnow Support Project you can do so by clicking on the following links: 50SP, 100SP, 250SP, 500SP, 1000SP, 5000SP.
Be sure to leave at least 50SP undelegated on your account.

Hey, @tdre!

Thanks for contributing on Utopian.
We’re already looking forward to your next contribution!

Get higher incentives and support Utopian.io!
Simply set @utopian.pay as a 5% (or higher) payout beneficiary on your contribution post (via SteemPlus or Steeditor).

Want to chat? Join us on Discord https://discord.gg/h52nFrV.

Vote for Utopian Witness!

Hi @tdre!

Your post was upvoted by @steem-ua, new Steem dApp, using UserAuthority for algorithmic post curation!
Your UA account score is currently 3.779 which ranks you at #4699 across all Steem accounts.
Your rank has improved 159 places in the last three days (old rank 4858).

In our last Algorithmic Curation Round, consisting of 211 contributions, your post is ranked at #1. Congratulations!

Evaluation of your UA score:
  • You're on the right track, try to gather more followers.
  • The readers like your work!
  • Good user engagement!

Feel free to join our @steem-ua Discord server

Coin Marketplace

STEEM 0.20
TRX 0.13
JST 0.029
BTC 66892.02
ETH 3513.87
USDT 1.00
SBD 2.67