Tech It Easy: 2016

Tuesday, 15 November 2016

Chrome Extension - the way I used it




Sequel of bookmarking-javascript-way-i-used-it is this Chrome Extension

Are you a google chrome user ? Cheers

It is google chrome specific candy - Chrome Extension

To create sample chrome extension by yourself: https://robots.thoughtbot.com/how-to-make-a-chrome-extension

manifest.json:
{
  "manifest_version": 2,
  "name": "miApp Filler Extension",
  "version": "0.1",
  "content_scripts": [
    {
      "matches": [
        "http://localhost:8080/miApp*"
      ],
      "js": ["fillAndSubmit.js"]
    }
  ]
}

fillAndSubmit.js: (might not be the optimal way)
function getById(id) { return document.getElementById(id); }
setTimeout(function() {
        if(getById('gwt-debug-login-username')){
            getById('gwt-debug-login-username').value='Superuser'; 
            getById('gwt-debug-login-password').value='Superuser'; 
            getById('gwt-debug-login-submit-button').click(); 
        }
    }, 1000
);

Adding it to Chrome: 

In new tab type chrome://extensions/ and enter

1. Make sure you have checked the Developer mode in chrome extensions.


2. Check on Allow in incognito checkbox (if required)




That's it.

Using it:

As soon as you open the App login page (by clicking a bookmark), the new chrome extension will fill the form and submits it.

Saturday, 22 October 2016

Bookmarking javascript - the way I used it




geb-get-into-groovey-way-i-used-it is modified into Bookmarking JavaScript

I have learned to bookmark JavaScript from Visual Event. This can be used to fill your login forms and submit with single click (clicking bookmark basically)

javascript:(function(){
    document.getElementById('gwt-debug-login-username').value='Username';
    document.getElementById('gwt-debug-login-password').value='password';
    document.getElementById('gwt-debug-login-submit-button').click();
})();

The Problem:
Each time when I want to open my application in some browser like chrome for testing or whatever, the following are the sequence of things I do (it is pretty similar with every other web based project or application)

If you want, use it at your own discretion

1. Put the URL in the URL bar (or clicking the bookmark)
2. As my app starts with a login page, I provide username, password (is a trivial one and not that sensitive),
3. Click on Submit button to login  and proceed with my intended work.

Rescue:
Here comes the JavaScript Bookmarking to rescue us, (works in Firefox and Chrome)

Creating it:

1. Bookmark any link with name of your choice ex: "fill and submit" (on the bookmark bar)



2. Right-click on the newly created bookmark and select edit option



3. Paste the JavaScript code in the URL textbox and hit save.




That's it.

Using it:

Once you open the App login page (by clicking a bookmark), you can then click on the new bookmark we created to fill and submit the login page.


What next:

Making a chrome extension to detect and fill login page without clicking another bookmark