afuna: Cat under a blanket. Text: "Cats are just little people with Fur and Fangs" (Default)
Have finally redownloaded Google Chrome because I need it for some troubleshooting. Before doing so, I looked up how to disable auto-update, and discovered that it's now a matter of changing a setting via the Terminal, rather than deleting the auto-update program. This seemed a lot less virus-like creepy, so I have Google Chrome on my system right now, and feel okay about it.

While moving over settings, I discovered I'd have to restart Firefox -- shutting down Firefox took over an hour! And ate up all my CPU! I had to force-quit it after all; luckily didn't lose any data.

As a bit of amusement, I decided to see what it would take to get me to switch over to use Google Chrome regularly. At a minimum, I'd need:

  • Adblock and/or JS blocker (I went with Adblock, but I'll try to retain all my casual browsing on Firefox with NoScript on)
  • Something to keep count of open tabs (settled on TabGlutton)
  • Ability to quickly edit and preview CSS (probably somewhere, but I haven't looked for it; just the current hacky ways are enough for now)
  • Firebug or equivalent (built-in)
  • Greasemonkey script support (built-in)
  • ReadItLater (Found ChromeItLater; slightly clumsier than the official extension Firefox, but workable)
  • A JS shell (I have a bookmarklet, but I eventually decided to go with the jsshell extension)
  • a JSON prettifier (JSONView for chrome)
  • The ability to copy just the link text instead of the link address


I found what I needed, or a good-enough equivalent, for everything but the last one. Searching through the extensions site and through the greater web turned up nothing. So.... I ended up writing my own.

screenshot )

It didn't take long; however, figuring out the difference between the content_scripts side (which lets you manipulate the webpage) and the main extension body in background_html (which lets you manipulate the browser behavior) took some doing.

The basic "hello world" example shows you how to create a regular extension, one which interacts with the browser. It took me an embarrassingly long time to figure out there was something beyond that.

After I figured out that the reason my extension wasn't doing anything was because it was running once when the extension loaded, when it needed to be running once per page, I slowly came to the realization that I'd need something like body.onload. Unfortunately, even after going through all the links from the getting started portion of the tutorial, I had still overlooked the other part of the API which would enable me to interact on a per-page basis (hello content_scripts!). I tried to force it by using chrome.tabs.onUpdated.AddListener... if ( changeInfo.status == "complete" ) as a poor extension writer's body.onload and that worked, but wow was it ugly :D

I can't remember how I found the link, but after finding that section in the documentation, I was more than halfway there.

In my initial version, I tried to programmatically create a range (document.createRange()) to select the text in the content scripts portion of the page. Right after that, I'd rely on some timing hackery to run document.execCommand("copy") (yeah I didn't know this function existed until now either) in the extension trusted area. It worked, ish, but was ugly and hacky and brittle.

Reason I had to put document.execCommand in the extensions area: it seems to need to be run with higher privileges. If it were available to the website, any website could see your clipboard, and that could potentially leak information. Since extensions are more trustworthy -- you choose whether to install them, and I believe they're vetted to some extent by reviewers before they are distributed in the gallery, they are allowed to execute with higher privileges than Joe Random Website.


On the second version, I figured out I could send just the relevant information (the link text) to the main extension body via a communication pipe, and have the copying take place there. That took away all the worst of the brittleness and most of the hackishness (there still is some ;-)), as well as gave me some flexibility for being able to output in multiple formats should I choose to code that in in the future, and I am quite happy with the results.

I can't take credit for it though: I had the glimmerings of the idea on my own, but I didn't actually get it to work until I peeked into the source code of Auto Copy.

So anyway, there it goes. Have made a Google Chrome extension, it wasn't very painful once I managed to wrap my mind around how everything fit together, and I'm happy with the results.


Ohh one final thing: for a long time, I thought that console.log() didn't work in extensions, and struggled with that. It turns out:

a.) console.dir in Google Chrome is the equivalent of console.log in Firebug; and
b.) If your console.log calls are in your main extension body, you need to open the background.html view from the extensions tab, as the console log output is put there. If your console.log calls are in a content_scripts js file, then they'll show up in the webpage

And there! :D
afuna: Cat under a blanket. Text: "Cats are just little people with Fur and Fangs" (Default)
(Or: when your focus listener interferes with your click listener) Demo.

Stumbled across it while I was working on the new update page, and it held me up a while. Eventually, I decided to use another approach.

Playing with the thought of submitting it as a bug, but it may be expected quirky behavior -- at least, it behaves the same way in both Firefox and Opera. Chrome, meanwhile, does not suffer from the problem, but that may be sheer accident: Chrome doesn't trigger the focus event when you use the mouse, only when you use the keyboard. So in Firefox/Opera, the click event doesn't work; in Chrome, it's the focus event that doesn't show up.

Browsers: they are strange animals.

PS. If you edit the URL to see previous versions of the fiddle, you'll see that I originally thought that the presence of images had something to do with it, ehehe.
afuna: Cat under a blanket. Text: "Cats are just little people with Fur and Fangs" (Default)
Really simple script for you guys today: Support: Summary in Title.

That appends the the request summary into the window title which lets you the request summary show up in your browser history. Meaning, you can just type in a partially remembered request summary in your browser address bar, and it'll (hopefully) pop up the URL to the request you're thinking of.

Works on Dreamwidth and LiveJournal. (Note that it may be conflicting with some other scripts? I had to drag it to the beginning of my list in the Greasemonkey settings for it to work on LiveJournal)

Resisting urge to code

Saturday, May 30th, 2009 11:23 am
afuna: Cat under a blanket. Text: "Cats are just little people with Fur and Fangs" (Default)
I am resisting the urge to see how easy it would be to convert an extension, which works in FF2 but doesn't in FF3, to use Jetpack.

I had in mind Delicious Complete, as the only relatively simple non-FF3-compatible extension I'm aware of. It seems so easy, especially if I can just use the jQuery plugins!

Unfortunately (or fortunately), I find myself unable to decide how to include said plugins (I could copy and paste, or reference remotely using $.getScript, both of which have advantages and disadvantages, and I cannot decide!)

Resisting urge to code. Resistance weak. Maybe I should look through my extensions to see which ones say they're incompatible with the version of Firefox I'm using, and try rewriting the simpler ones out of curiosity.
afuna: Cat under a blanket. Text: "Cats are just little people with Fur and Fangs" (Default)
I'm playing around with Jetpack. Probably won't have time to write any scripts, but one demo, in particular, caught my eye.

Tab Grapher: it shows you a graph of the number of tabs you have open in your browser over time.

I WANT. I NEED.

I HAVE.

ETA: They also have an ad-blocker, written in approximately 100 lines. I'm trying it out of curiosity (I've never used an ad-blocker before, though). Hmmm, now I'm fighting the urge to extend it to store the number of times that I block an ad on any site.

(What's stopping me is that I can't decide between counting the number of times a particular ad is blocked, or the number of ads on a particular site)

Chickenfoot

Friday, February 29th, 2008 04:40 pm
afuna: Cat under a blanket. Text: "Cats are just little people with Fur and Fangs" (Default)
I just found an alternative to Greasemonkey, called Chickenfoot. I think... it may abstract away some of the more technical language, and it is less sandboxed than Greasemonkey. So basically, more like an extension than a script. If that is true, I wonder how they stop malicious websites or scripts from gaining access? I'm curious; must set aside time (I don't actually have) to play.
afuna: Cat under a blanket. Text: "Cats are just little people with Fur and Fangs" (Default)
So after switching to Firefox 3 beta, I found that a lot of my extensions no longer worked, which I expected. What I didn't expect was how much I'd miss the invisible extensions. These are the extensions that don't require any configuration, don't have to be triggered by any buttons, don't show up in the interface; they just work.

I could get used to losing "Colorful Tabs", and have my tab bar be a dull monochromatic gray. It was losing Tabs Open Relative (and Submit to Tab) that I've found really irritating, because there are no visual indicators that they no longer work. I only find out/remember when I try to open a new tab, and find myself at the end of the tab bar, not beside my current tab. Just a few minutes ago, I restarted Firefox (because I keep forgetting that the RTE pop-up windows won't work with Firefox 3 and I can't close that pop-up otherwise), clicked on a link... and it opened beside my current tab.

I feel so incredibly happy! This is almost better than if the Web Developer toolbar had been updated -- almost.
afuna: Cat under a blanket. Text: "Cats are just little people with Fur and Fangs" (Default)
I'm trying out Firefox 3(.0b3) right now! I decided to download it on a whim; I was hoping that it would be less of a memory hog than Firefox 2. Because trying to run that plus Aptana (Ruby IDE) at the same time was bogging down my system horribly. For the record, it seems to be running more smoothly, but the test may not be fair since most of my extensions were disabled for being incompatible *g*

I love the new features, including the improved downloads interface, additional interfaces (such as the new Applications item, which is the filetype-to-action mapping) and what look to be better error messages. One of my favorite things is that there is now a shortcut for the JavaScript console. It may not seem like much, but the inefficient way to open the JavaScript console has always been one of those little things that irritated me to no end.

It is somewhat strange to see the form controls be styled like Safari's. And the window is a darker gray than I'm used to. I am not enamoured, but I guess I'll get used to them.

There are a few rough spots; sometimes the rendering is weird and elements show up in the wrong place on the page (the header for Vertigo does this often on the Explore page). Also, the cmd+shift+T shortcut does not seem to always work; I often have to use the menu instead. I'm hoping that these kinks will be worked out by the time it makes it to release.

I'm excited about their moving the preferences storage backend to SQLite instead of writing to the textfile (prefs.js) only when closing the browser properly. I think this affects the values saved by Greasemonkey as well; if so, then that means I won't lose the data from the current session if the browser suddenly crashes. I am almost tempted to try to crash something so I can test :-)

I'm also excited about the improved search and bookmarking (with tags) functions -- searching through the address bar brings up results based on the address, the page title, bookmarks, bookmark tags, and I'm finding it pretty useful. (For example, when doing Support work, I can just type "entryprops" and get the URL I want, instead of having to type "livejournal.com/admi...", selecting whatever URL comes up, then deleting the end and triggering autocomplete again with "entr..."). There's also apparently auto-resume for downloads, though I have not tested it yet.
afuna: Cat under a blanket. Text: "Cats are just little people with Fur and Fangs" (Default)
Oh interesting. If I add "&client=firefox" to the parameters in a Google search, it redirects me from http://www.google.com to http://www.google.com.ph. The navigation links at the top left hand side are different, as are the order of the search results.

Any value that starts with "firefox" will do. For example, these URLs pass me back to google.com.ph:
http://www.google.com/search?q=aveleh&client=firefox
http://www.google.com/search?q=aveleh&client=firefox-a
http://www.google.com/search?q=aveleh&client=firefoxgibberish

However, taking out the &client, or giving it a value that does not start with "firefox" does not perform the redirect. For instance:
http://www.google.com/search?q=aveleh&client=gibberish
http://www.google.com/search?q=aveleh&client=opera

Finally, the redirect doesn't work if I specify the country:
http://www.google.ca/search?q=aveleh&client=firefox


I wonder how it affects people in other countries? I'm guessing it will probably redirect to your country-specific Google domain.

(This all started because a search for "arno tom ponnixry" returned only results for my journal. And then we found out that searching for "aveleh" returned my journal as the fourth result in [livejournal.com profile] aveleh's Google search, but as the first result of mine. From there, it was a short step to me comparing both URLs for differences, and accidentally stumbling upon the auto-redirect.)
afuna: Cat under a blanket. Text: "Cats are just little people with Fur and Fangs" (Default)


What should actually be showing up in that entry is the welcome video of OSX Leopard.

It's definitely not something being done by lj-toys, and I get the ad-filled page when I visit the page directly, so it's not just within the iframe. Somehow, Firefox is directing me to the wrong site/domain. But how? And why?

Not cache, because it persists after I clear and restart.
Not an extension, because I'm reproducing in an empty profile. Actually, for that reason, shouldn't be cache, either.

nslookup from my machine returns a different result versus the nslookup from [livejournal.com profile] ciaran_h's server. Plus, lj-toys works properly on Safari, but not on Firefox; I don't know why.

nslookup results )

Fu: 0
That site: eleventy-one

Update:
Dre fixed it <3 Added a line to /etc/hosts, and now I have no problems. It's hacky, but it works. *purrs at Dre*

Bring on the extensions

Wednesday, June 20th, 2007 09:30 am
afuna: Cat under a blanket. Text: "Cats are just little people with Fur and Fangs" (Default)
It turns out I can only live without Tabs Open Relative and SubmitTo(New)Tab for one day. Without Greasemonkey for two.

----

OH MY GOD I thought today was going to be a lazy day, but now I'm wide awake.

January 2017

S M T W T F S
1234567
891011121314
1516171819 2021
22232425262728
293031    

Syndicate

RSS Atom

Most Popular Tags

Expand Cut Tags

No cut tags