Giter Club home page Giter Club logo

autofiller's Introduction

autofiller

Simple utility designed to easily create autofiller bookmarklets.

Use case and example

When going to read the newspaper online, I often find that the site disconnected me. I have to click on "Connection", wait for the popup to show up, fill my username and password, and then click "login". It's easy, but tedious and I'm lazy.

Instead, I'd like to press a single bookmark button, on any site, and it will fulfill these tasks for me. The API should be as simple as:

doOnPage('myFavoriteNewspaper.fr', async () => {
  findInputByText('Connection').click();
  await wait(1000);
  findInputByText('username').setValue('my username');
  findInputByText('password').setValue('secret');
  findInputByText('login').click();
});

^ Let's call this the driver code.

How to use this?

  1. Open a text file, type
javascript:(() => {...})()
  1. Replace the ... by the content of autofill.js and your driver code. Copy all the text.

  2. In you favorite browser, create a new bookmark. Instead of a URL, paste the text.

  3. Go on the website you intend to drive, and click the bookmarklet.

API details

Hopefully, findInputByText can find what you want. It will look for an input that have at least a part of the query text:

  • by label text
  • by innerText (buttons, links: the text can be nested)
  • by placeholder (exact text, no partial match)
  • by name (exact)
  • by id (exact)

If you want more granularity, consider extending findInputByText to keep the API simple, or use the building blocks of findInputByText directly.

These are ordered by preference: hopefully we should not need to look at name and id, but the Web is hard, so these are useful escape hatches. Content in iframes is currently not handled, and won't be found.

doOnPage accepts a regex: window.location.href.match(urlFragment).

wait takes a wait time in ms.

If an input is not found, something that quacks like an input (responds to setValue and click) but does nothing will be returned. This is convenient when the url does not change, but the page content does (true single page app).

autofiller's People

Contributors

qbalin avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.