Viewing posts tagged with snippet

Password Generator Bookmarklet

I created this little bookmarklet a few days ago to instantly create a random 10 character password. It's pretty handy as I'm always needing to create a new secure password.

If you need it more secure, you can edit the character list in the str variable, and edit the length of the password via the for loop. In this version, I've stripped out characters that look alike as it's annoying when can't tell exactly what the character is.

javascript: (function () {
    var tmp = '';
    var str = '23456789abcdefghjkmnopqrstuvwxyzABCDEFGHJKMNPQRSTUVWXYZ';
    var len = str.length;
    for (var i = 0; i < 10; i++) {
        tmp += str[Math.floor(Math.random() * len)];
    }
    prompt('Your randomly generated password is:', tmp);
})()

To use it, simply drag the link below onto your browser toolbar, and then click it when you want to create a random password.

Generate Password

Flickr and Youtube Bookmarklet

Here is a little bookmarklet I created to grab the short URL when viewing a video on YouTube or a photo on Flickr:

javascript: (function () {
    var a = location.host;
    if (a.indexOf('flickr') > 0) {
        var a = document.getElementsByTagName('html')[0].innerHTML;
        var b = a.match('http://flic.kr/p/([_a-zA-Z0-9]*)');
        if (b) prompt('The flic.kr URL is:', b[0]);
    }
    if (a.indexOf('youtube') > 0) {
        var a = document.getElementsByTagName('link');
        for (var i in a) {
            var b = a[i];
            if (b.getAttribute('rel') == 'shortlink') prompt('The youtu.be URL is:', b.getAttribute('href'));
        }
    }
})()

To use it, simply drag the link below onto your browser toolbar, and then click it when viewing a video or photo.

Grab Short URL