| |||||||
| Top Tip : Click here to Boost Your PC & Chrome Browsing Speed |
![]() |
| | Thread Tools | Display Modes |
|
#1
| ||||
| ||||
| This is from Vhanla's post on "Another Site" (It is not created by me!!): Hi folks, today I will teach you how to take advantage of the built-in userscript feature of Google Chrome to have a mouse gesture for navigating through history, I mean, back and forward. First you need to have that feature enabled, so you need to activate that with these simples steps (if you don't know how) For XP users go to Default folder (or the profile you're using) and create the directory "User Scripts" just like this C:\Documents and Settings\<you username>\Local Settings\Application Data\Google\Chrome\User Data\Default\User Scripts For Vista or 7 users C:\Users\Administrator\AppData\Local\Google\Chrome \User Data\Default\User Scripts After that you need to start Google Chrome with "--enable-user-scripts" parameter And finally the UserScript: Code: // ==UserScript==
// @name Mouse Gestures for Google Chrome
// @author vhanla
// @namespace http://www.codigobit.net/
// @version 1.0
// @description Allows to use mouse gestures for navigating through pages
// @include *
// @exclude
// ==/UserScript==
(function() {
var posx = 0;
var estado = false;
var gestdown = function() {
if (event.which)
button= (event.which < 2) ? "LEFT" :
((event.which == 2) ? "MIDDLE" : "RIGHT");
if (button=="RIGHT"){
estado=true;
posx=event.clientX;
document.oncontextmenu = new Function("return false")
}
}
var gestup = function() {
if (estado){
estado=false;
if(event.clientX+100<posx){
window.history.back();
}
else if(event.clientX-100>posx){
window.history.forward();
}
else void(document.oncontextmenu=null)
}
}
window.addEventListener("mousedown", gestdown, false);
window.addEventListener("mouseup", gestup, false);
})(); Ok, that is all, now you can hold the right button and drag back or forward in order to navigate. I prefer this method instead of having external programs. I don't know how to send keystrokes with javascript. However, I would suggest another method just like Opera. Code: // ==UserScript==
// @name Mouse Gestures for Google Chrome
// @author vhanla
// @namespace http://www.codigobit.net/
// @version 1.0
// @description Allows to use mouse gestures for navigating through pages
// @include *
// @exclude
// ==/UserScript==
(function() {
var posx = 0;
var posy = 0;
var estado = false;
var gestdown = function() {
if (event.which)
button= (event.which < 2) ? "LEFT" :
((event.which == 2) ? "MIDDLE" : "RIGHT");
if (button=="RIGHT"){
estado=true;
posx=event.clientX;
posy=event.clientY;
document.oncontextmenu = new Function("return false")
}
}
var gestup = function() {
if (estado){
estado=false;
if(event.clientX+50<posx){
window.history.back();
}
else if(event.clientX-50>posx){
window.history.forward();
}
else if(event.clientY-50>posy){
window.open("http://www.speedymarks.com");
}
else void(document.oncontextmenu=null)
}
}
window.addEventListener("mousedown", gestdown, false);
window.addEventListener("mouseup", gestup, false);
})(); Well for disabling you can add the following code into this existing one Code: var notooltips = function() {
var titles = document.getElementsByTagName("a");
for (var x = titles.length - 1 ; x>=0;x--)
titles[x].title = "";
var titlestd = document.getElementsByTagName("td");
for ( x = titlestd.length - 1 ; x>=0;x--)
titlestd[x].title = "";
var alts = document.getElementsByTagName("img");
for (x = alts.length - 1 ; x>=0;x--)
alts[x].setAttribute('title','');
}
window.addEventListener("load",notooltips, false); Last edited by Stamga; 04-15-2009 at 08:44 PM.. |
|
#2
| |||
| |||
| This script stopped working a few versions ago. It's too bad because it was a feature that I really used it. I modified the script a little bit and now it looks like this: Quote:
1. save the script as mousegestures.js 2. I took a manifest.json from another extensions and modified it to take the mousegestures.js script 3. I archived those two files into a zip file and renamed it to crx. 4. I dragged the crx file into the main chrome window and it installed succesfully but no effect. Maybe someone with more experience can do this extension for us. It's really the missing piece in chrome. |
|
#3
| |||
| |||
| The new one doesn't work for me either ![]() My Chrome is 3.0.182.3 (dev channel). The only thing that I notice in Java Script console is this: Code: Uncaught TypeError: Cannot read property 'which' of undefined Thanks |
|
#4
| |||
| |||
| So I guess that Chrome's new versions does not support event.which. I've searched around and couldn't find a replacement for it. I think if this is fixed, the first mouse gesture extension for Chrome it will be out. Anyone any ideas ? I can't see any message in Java Script Console. I tried replacing the first part of the script like this: (function() { var posx = 0; var posy = 0; var estado = false; var gestdown = function() { if (event.button==2){ estado=true; posx=event.clientX; posy=event.clientY; document.oncontextmenu = new Function("return false") } Can you test it to see what message do you get ? Thank you Last edited by alinescoo; 06-01-2009 at 06:44 AM.. |
|
#5
| |||
| |||
| No luck I tried with your changes but now I got:Code: Uncaught TypeError: Cannot read property 'button' of undefined I hope this helps you. Thanks |
|
#6
| |||
| |||
| With a friends help we managed to get the script running from a test page. I attach an example, just unzip those files to c: and open the sample page with Chrome. Right click and drag down, it should open a new tab. I don't know what to do to make it run on all chrome windows.... Anyone ? We are getting closer, I feel it Last edited by alinescoo; 06-01-2009 at 08:05 AM.. |
|
#7
| |||
| |||
| If you can place it into a page like you did, it should work as a content script / user script. If you try it and it doesn't work, post the error and i'll try to help. |
|
#8
| |||
| |||
| As I mentioned before, let's take for example the following version of the script: Quote:
If I create User Scripts folder in Chrome profile folder and add --enable-user-script starup parameter, when I try to make a gesture in debug I get the folowing error (as mentioned above) Quote:
Whatever I tried to fix this, I couldn't. I could really use your help. Thank you. LE: I must say that in version 2.0.168.0 it works like a charm. So something must have changed in the latest builds. I'm sure it's just a little thing, but I am fully unexperienced with this. |
|
#9
| |||
| |||
| Code: Uncaught TypeError: Cannot read property 'which' of undefined It means that the "event" object is undefined. (It's kind of like a null pointer exception) Try passing as a parameter to the "gestdown" and "gestup" function an object named "event". Code: var gestdown = function() { Code: var gestdown = function(event) { |
|
#10
| |||
| |||
| I can confirm that the script from the test page works great, even the back works (I opened the test page in an already open tab). I can always go back to 2.0.168.0 but I got the feeling that you are close too |
![]() |
| Thread Tools | |
| Display Modes | |
| |
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Chrome Mouse Gestures? | Wisher | Chrome Plugins | 36 | 10-21-2009 03:16 AM |
| Back / forward buttons on mouse | Illway | Bugs and Vulnerabilities | 1 | 03-26-2009 11:55 PM |