Saturday, November 12, 2011

Opera Fullscreen Autoshow/hide Toolbar

Another thing missing from Opera is the fullscreen mode autoshow/hide toolbar. Yes, there are ways to show and autohide the toolbars with delay using keyboard shortcuts and mouse gestures as described here, however, often time we (especially netbook users) just want to use our mouse to show the address bar or tab bar to navigate back/forward or to switch tabs.

So, my idea is, when we go to fullscreen mode, we add a handler to detect when the mouse reach the top of the screen, and when it does, we would like to send Opera the show toolbars shortcut. I have searched through Opera Extensions API if there is a way to send an internal Opera action command through an extension, but so far the result is none. So, finally, I decided to utilize Autohotkey to the rescue. Basically I wrote a script to detect when Opera is active, and detect when mouse position reach top of the page, then send the keyboard shortcut to Opera.

#NoTrayIcon ; Uncomment this line to show Tray Icon
SetTimer, CheckOpera, 1000

if WinActive("ahk_class OperaWindowClass")
   MouseGetPos, xpos, ypos
     if (ypos = 0) {
     Send {Shift Down}{F11}{Shift Up} ; Put your shortcut here, in this case: Shift F11

How to use the script:
1. In Opera, define the keyboard shortcut key to show and autohide the toolbars
For this example I define Shift F11 shortcut as View page bar, 6 & View address bar, 6 & Delay, 10000 & View page bar, 0 & View address bar, 0
Note: View page bar = show tab bar

2. Download Autohotkey, write the script above, and if you wish, compile it to standalone executable (.exe)

3. Run the script on Windows startup, or on Opera startup using Opera Launcher

Give it a try, and as always, suggestions and comments are welcome :)

Saturday, October 15, 2011

iFrame Opera Extension (Updated for Opera 39)

My First Ever Published Opera Extension :D

Based on my previous post, iFrame bookmarklet, with added capability to resize and move the iFrame

Try Opera, and try my extension :)

Update Version 0.6-0.7: After 3+ years, I finally found the time to edit this extension to work with the new version of Opera (Chromium). Tested and Published for Opera 39. I don't know how many will actually come back and reuse this extension, but well, at least I'm using it extensively myself :)

Thursday, October 13, 2011

Browsing with iFrame

For me, Opera is (almost) perfect. The only thing missing is an extension like Firefox's CoolPreviews or Google Chrome's extension ezLinkPreview. So here I end up writing it myself ... a simple inside Frame browsing. The idea is basically if you have several links on a page (like Google search results) instead of clicking a link, go back, click another link, go back, you can just open an iframe (still on the same page) to "preview" the destination link, and when you decide to browse the entire content, you just need to click the actual link to load the whole page. This is very helpful when browsing pages with hundred links, such as Craigslist!!

How to use: Drag this bookmarklet to your bookmark bar, and click it when you are on a page that you need the iFrame. When you hover on a link, it will display a small box on the right side of the link, which you can click to open the preview frame. Click outside the frame to close it, or hover and click on another link.

iFrame Bookmarklet

For Opera user, you can add this javascript file iFrame.user.js to your UserJS folder to load iFrame functionality every time you open a webpage.

Update: For Opera user, you can download the iFrame extension here, with added capability to resize and move the iFrame.

Update 2: Below is the draggable and resizable version of iFrame Bookmarklet (only works in Opera for now)

iFrame Bookmarklet

Enjoy! Suggestions and comments are always welcome.

Monday, June 27, 2011

Get Images Bookmarklet

I wonder why all Internet browsers do not provide us with a built-in and simple way to download multiple images, such as those excellent photos from my favorite's The Big Picture. The closest thing that fit my need is Bulk Image Downloader and Firefox Extensions (Image Picker). The thing is, I certainly don't want to pay for something that can be free, and secondly, I don't use Firefox as my primary Internet browser (Hail Opera!)

My first plan was to make an Opera extension similar to Firefox's Image Picker, which basically read a page, select the images and then call the built-in download manager to save it to local folder. However, I'm having a real hard time finding the Opera API function to call the Opera download manager to download even a single url. So, I end up writing just this simple bookmarklet to grab the images url, and execute Free Download Manager to perform the download. For now, the bookmarklet only extract direct source url of images on the page, not linked images (such as google image search, flickr, etc.)

UPDATE: It now extracts the real image url of Google Image Search and Yahoo Image Search results :)

UPDATE 2: For Opera User, the bookmarklet will extract the url in links, so you can use the Link Panel, Select All, and Save to Download Folder. No longer need to copy paste to Free Download Manager.

You can add this link to your bookmark folder or drag it to your Opera Bookmark Bar
Get Images Bookmarklet

UPDATE 3: Added Check / Uncheck All Buttons Get Images Bookmarklet v3

UPDATE 4: Add Bing image search support Get Images Bookmarklet v4

Google Chrome or Firefox version of the bookmarklet: Get Images

Here is how you use it:

1. Go to your favorite image gallery site. Here are some of my favorites:

2. Click the Get Images Bookmarklet from your bookmark folder or Bookmark Bar, it will open a new page with all the images from the site resized along with a checkbox next to each images

3. Check or uncheck the images you want to download, and the image source url will be copied to the textarea.

4. Select all (Ctrl + A) and Copy (Ctrl + C) the links in the textbox

5. Open Free Download Manager, choose Import list of URLs from clipboard (Ctrl + Shift + V)

Comments are greatly appreciated :)

Wednesday, June 08, 2011

#coding=utf-8 Facebook Simple Notifier
#  by Herry Limantoro (
#NOTE: Don't forget to Add the Mechanize source folder into your SL4A scripts folder (/mnt/sdcard/sl4a/scripts)

import android
import time
import sys
import traceback
import urllib
import mechanize
import BeautifulSoup
import re

droid = android.Android()

#Setup Browser
br = mechanize.Browser()

#User Agent, can't do without it
br.addheaders = [('User-agent','Mozilla/5.0 (X11; U; Linux i686; en-US; rv: Gecko/2008071615 Fedora/3.0.1-1.fc9 Firefox/3.0.1')]

url = ''

#Set username password here, leave blank to prompt for username/password
username = ''
password = ''

#Set run interval (in minutes), prompt if 0
interval = 0

def get_interval():
  droid.dialogCreateAlert('Run interval (in minutes)')
  droid.dialogSetItems(['5', '15','30','60'])
  response = droid.dialogGetResponse().result['item']
  if response == 0:
    interval = 5
  elif response == 1:
    interval = 15
  elif response == 2:
    interval = 30
  elif response == 3:
    interval = 60
  print "Run every " + str(interval) + " minutes"
  return interval

def run_loop():
  val = True
  errcount = 0

  #keep CPU run, still can't find other workaround

  while val:
    runTime = time.strftime('%Y%m%d %H%M', time.localtime())
    print 'Run at: ' + runTime
      val = get_notifications()
    except Exception, err:
      print err
      droid.notify('FBNotify Error at ' + runTime, str(err) + '\nCheck SL4A Console for detail')
      errcount = errcount + 1

    #last 3 run produce exception
    if errcount > 3:
      val = False
    if val:
      time.sleep(interval * 60)


def get_notifications():
  print 'Connecting to Facebook...'

  if br.viewing_html() is False:
    print 'Viewing HTML Error'
  elif 'Notifications' in br.title(): 
    #Already logged in
    print 'Notification page'
    #Redirected to Login Form
    print 'Login ' + username

    #Select Form, Fill in username password, and Submit
    br.form['email'] = username
    br.form['pass'] = password
    resp = br.submit()

    if br.viewing_html() is False:
      print 'Viewing HTML Error!'
    elif 'Notifications' in br.title():
      print 'Logged In! Notification page'
      #if not logged in, most likely wrong username password
      print 'Login Error!'
      #Play some tone
      droid.notify('FB Login Error - Program Exit','Check your username password')
      #logical thing to do is exit program
      return False

  return True

def process():
  soup = BeautifulSoup.BeautifulSoup(br.response().read())

  #Get all classes containing 'acw apm' (Check your FB notifications.php source if different)
  nodes = soup.findAll('div',{'class':re.compile(r'.*\bacw apm')})
  msg = ''
  count = 0
  for node in nodes:
    line = ''
    for content in node.contents:
        line = line + content.string
        line = line

    #New notification indicator
    dot = u'•'
    if line != '':
      #print out all notifications
      print line.encode('utf-8')

      #collect the new ones only to notify
      if line[0] == dot:
        if count == 0:
          msg = line
          msg = msg + '\n' + line
        count = count + 1

  if count > 0:
    print 'New notifications:'
    print msg.encode('utf-8')

    #Play some tone

    #display notification
    droid.notify('You have ' + str(count) + ' FB notifications', msg)

    #uncomment to show toast message
    print 'No new notification'

#Main program
valid = True
  if username == '':
    username = droid.dialogGetInput('Username','Your Facebook username').result

  if password == '':
    password = droid.dialogGetPassword('Password', 'For ' + username).result

  if interval == 0:
    interval = get_interval()
  valid = False

if valid:

Android Facebook Simple Notifier using SL4A

Like many Android phone users, I wonder why the Android Market Facebook app lacks push notifications like BB or iPhone. Currently it only notify when there is new message, or event and friend request. So, when I get acquainted with SL4A, this is the first app pop up in my mind. However, reading through the Facebook API and having to handle oAuth and stuffs seem just too much work. So, I thought if only I could open my mobile version of FB notification page ( and read the new notifications, that would do it. And upon googling on emulate browser using python, I found these two excellent tutorials:

 I guess the neat trick is to "disguise" the User Agent of the mechanize Browser. From there on, it's basically parsing the HTML source behind the notification page. One last bit is detecting the bullet list character as the indicator of new notifications, which actually made me lost in encoding decoding -.-. Oh ya, I couldn't work out the wakeLockAcquirePartial and wakeLockRelease without messing up the sleep timer. So I ended up just calling wakeLockAcquirePartial to keep the CPU run all the time while the phone is locked and screen is off. But well, at least it works :D. And oh, have I said I did all the coding and debugging on my Samsung Galaxy Gio phone :P?

Here is what you need to do:

(You can click the links, or you can just scan the barcodes)

1. Install SL4A and Python for your Android phone


2. Download Mechanize for python (stable zip), extract, copy only the mechanize source folder to SL4A scripts folder on your phone (/mnt/sdcard/SL4A/scripts/)

 3. Download the script and save it to SL4A scripts folder

For those having trouble getting it from dropbox

4. Try it out, let me know if it doesn't work, Enjoy :D and tell others

5. Drop me a comment or e-mail me or join the SL4A Discussion Group