Update Request w/ Code
![]() ![]() |
Hello. I'm a learn-as-I-go Greasemonkey developer who discovered the concept of access keys a few months ago. I've created an updated version of your script, which you are free to use, release and maintain. If you opt not to continue supporting this script or I don't receive a reply in about a couple of weeks or so, I'll just use release this as a fork. Otherwise, I'd greatly appreciate it if you would consider the possibility of implementing the features mentioned below as TODO comments. My code is as follows:
var links = document.getElementsByTagName("a"); morelink=false;
/* Just doodling around to see what would happen if I applied accesskeys to the sidebar instead... var links = document.getElementById('ms').getElementsByTagName('li'); morelink=false;
if (morelink && typeof('morelink') != "undefined") {
EDIT: Google Dictionary seems to still use the same top menu bar since the code for the Wikipedia feature (which was not updated) worked and the rest of the script didn't on that site. |
![]() ![]() |
Awesome! I've installed your changes; some day, I might have time to do your todos! |
![]() ![]() |
ms609 wrote: Totally feeling ya there. If I had enough use for them to justify it, I probably would've already implemented them by now. So much code, so little time! Either I'm not using code tags right, or they just don't like me. The code I just gave ya got messed up, so here it is again. While at it, I put your old code back in because the Google Dictionary Chrome extension links to an old version of Google Dictionary which is compatible with your code but not mine.:
//TODO add j + k for next and previous pages
//TODO add a for advanced search
//TODO Consider adding access keys to GMail
var links = document.getElementsByTagName("a"); morelink=false;
for (i=0; i<links.length; i++) {
if (links[i].innerHTML == "Scholar") {links[i].accessKey = "s"; var scholar = links[i];}
//TODO Clean up
//Old code for older pages that do not have the new top menu bar layout
else if (links[i].innerHTML == "Web") {links[i].accessKey = "w";}
else if (links[i].innerHTML == "Images") {links[i].accessKey = "i";}
else if (links[i].innerHTML == "News") {links[i].accessKey = "n";}
else if (links[i].innerHTML == "Maps") {links[i].accessKey = "m";}
else if (links[i].innerHTML == "Groups") {links[i].accessKey = "g";}
else if (links[i].innerHTML == "Products") {links[i].accessKey = "p";}
else if (links[i].lastChild.innerHTML == "Web") {links[i].accessKey = "w";}
else if (links[i].lastChild.innerHTML == "Images") {links[i].accessKey = "i";}
else if (links[i].lastChild.innerHTML == "News") {links[i].accessKey = "n";}
else if (links[i].lastChild.innerHTML == "Maps") {links[i].accessKey = "m";}
else if (links[i].lastChild.innerHTML == "Groups") {links[i].accessKey = "g";}
else if (links[i].lastChild.innerHTML == "Shopping") {links[i].accessKey = "p";}
else if (links[i].lastChild.innerHTML == "Videos") {links[i].accessKey = "v";}
else if (links[i].innerHTML == "Realtime") {links[i].accessKey = "r";}
//TODO Fix
else if (links[i].className == "gb3" ) {morelink = links[i];}
}
/* Just doodling around to see what would happen if I applied accesskeys to the sidebar instead...
var links = document.getElementById('ms').getElementsByTagName('li'); morelink=false;
for (i=0; i<links.length; i++) {
if (links[i].innerHTML == "Scholar") {links[i].accessKey = "s"; var scholar = links[i];}
else if (links[i].lastChild.innerHTML == "Web") {links[i].accessKey = "w";}
else if (links[i].lastChild.textContent == "Everything") {links[i].firstChild.accessKey = "w";}
else if (links[i].lastChild.textContent == "Images") {links[i].firstChild.accessKey = "i";}
else if (links[i].lastChild.textContent == "News") {links[i].firstChild.accessKey = "n";}
else if (links[i].lastChild.innerHTML == "News") {links[i].accessKey = "n";}
else if (links[i].lastChild.innerHTML == "Maps") {links[i].accessKey = "m";}
else if (links[i].lastChild.innerHTML == "Groups") {links[i].accessKey = "g";}
else if (links[i].lastChild.innerHTML == "Shopping") {links[i].accessKey = "p";}
else if (links[i].lastChild.innerHTML == "Videos") {links[i].accessKey = "v";}
else if (links[i].innerHTML == "Realtime") {links[i].accessKey = "r";}
//TODO Fix
else if (links[i].className == "gb3" ) {morelink = links[i];}
}
*/
// The code beneath this line adds the "Scholar Pro" and Wikipedia links.
// Delete everything from here down if you want rid of them!
if (morelink && typeof('morelink') != "undefined") {
//TODO Fix
//Wikipedia
wiki = document.createElement("a");
wiki.accessKey = ("d");
wiki.style.fontWeight = "normal";
wiki.className = "q";
wiki.innerHTML = "Wikipedia";
w = /\Wq=([^&]*)/;
if (window.location.href.match(w)) {
var wikisearch = w.exec(window.location.href);
wiki.href = "http://en.wikipedia.org/w/index.php?title=" + wikisearch[1];
} else {wiki.href = "http://en.wikipedia.org/wiki/Special:Search?fulltext=Search";}
space = document.createElement("span");
space.innerHTML = " ";
morelink.parentNode.insertBefore(wiki, morelink);
morelink.parentNode.insertBefore(space, morelink);
}
EDIT: I Think I finally got this all figured out!!!
|
![]() ![]() |
Done. |
![]() ![]() |
One more update. Just thought I'd make the access keys for "Videos" and "Shopping" work on the old pages as well...
//TODO add j + k for next and previous pages
//TODO add a for advanced search
//TODO Consider adding access keys to GMail
var links = document.getElementsByTagName("a"); morelink=false;
for (i=0; i<links.length; i++) {
if (links[i].innerHTML == "Scholar") {links[i].accessKey = "s"; var scholar = links[i];}
//TODO Clean up
//Old code for older pages that do not have the new top menu bar layout
else if (links[i].innerHTML == "Web") {links[i].accessKey = "w";}
else if (links[i].innerHTML == "Images") {links[i].accessKey = "i";}
else if (links[i].innerHTML == "News") {links[i].accessKey = "n";}
else if (links[i].innerHTML == "Maps") {links[i].accessKey = "m";}
else if (links[i].innerHTML == "Groups") {links[i].accessKey = "g";}
else if (links[i].innerHTML == "Shopping") {links[i].accessKey = "p";}
else if (links[i].innerHTML == "Videos") {links[i].accessKey = "v";}
else if (links[i].lastChild.innerHTML == "Web") {links[i].accessKey = "w";}
else if (links[i].lastChild.innerHTML == "Images") {links[i].accessKey = "i";}
else if (links[i].lastChild.innerHTML == "News") {links[i].accessKey = "n";}
else if (links[i].lastChild.innerHTML == "Maps") {links[i].accessKey = "m";}
else if (links[i].lastChild.innerHTML == "Groups") {links[i].accessKey = "g";}
else if (links[i].lastChild.innerHTML == "Shopping") {links[i].accessKey = "p";}
else if (links[i].lastChild.innerHTML == "Videos") {links[i].accessKey = "v";}
else if (links[i].innerHTML == "Realtime") {links[i].accessKey = "r";}
//TODO Fix
else if (links[i].className == "gb3" ) {morelink = links[i];}
}
/* Just doodling around to see what would happen if I applied accesskeys to the sidebar instead...
var links = document.getElementById('ms').getElementsByTagName('li'); morelink=false;
for (i=0; i<links.length; i++) {
if (links[i].innerHTML == "Scholar") {links[i].accessKey = "s"; var scholar = links[i];}
else if (links[i].lastChild.innerHTML == "Web") {links[i].accessKey = "w";}
else if (links[i].lastChild.textContent == "Everything") {links[i].firstChild.accessKey = "w";}
else if (links[i].lastChild.textContent == "Images") {links[i].firstChild.accessKey = "i";}
else if (links[i].lastChild.textContent == "News") {links[i].firstChild.accessKey = "n";}
else if (links[i].lastChild.innerHTML == "News") {links[i].accessKey = "n";}
else if (links[i].lastChild.innerHTML == "Maps") {links[i].accessKey = "m";}
else if (links[i].lastChild.innerHTML == "Groups") {links[i].accessKey = "g";}
else if (links[i].lastChild.innerHTML == "Shopping") {links[i].accessKey = "p";}
else if (links[i].lastChild.innerHTML == "Videos") {links[i].accessKey = "v";}
else if (links[i].innerHTML == "Realtime") {links[i].accessKey = "r";}
//TODO Fix
else if (links[i].className == "gb3" ) {morelink = links[i];}
}
*/
// The code beneath this line adds the "Scholar Pro" and Wikipedia links.
// Delete everything from here down if you want rid of them!
if (morelink && typeof('morelink') != "undefined") {
//TODO Fix
//Wikipedia
wiki = document.createElement("a");
wiki.accessKey = ("d");
wiki.style.fontWeight = "normal";
wiki.className = "q";
wiki.innerHTML = "Wikipedia";
w = /\Wq=([^&]*)/;
if (window.location.href.match(w)) {
var wikisearch = w.exec(window.location.href);
wiki.href = "http://en.wikipedia.org/w/index.php?title=" + wikisearch[1];
} else {wiki.href = "http://en.wikipedia.org/wiki/Special:Search?fulltext=Search";}
space = document.createElement("span");
space.innerHTML = " ";
morelink.parentNode.insertBefore(wiki, morelink);
morelink.parentNode.insertBefore(space, morelink);
}
|
![]() ![]() |
One more update. Just thought I'd make the access keys for "Videos" and "Shopping" work on the old pages as well...
//TODO add j + k for next and previous pages
//TODO add a for advanced search
//TODO Consider adding access keys to GMail
var links = document.getElementsByTagName("a"); morelink=false;
for (i=0; i<links.length; i++) {
if (links[i].innerHTML == "Scholar") {links[i].accessKey = "s"; var scholar = links[i];}
//TODO Clean up
//Old code for older pages that do not have the new top menu bar layout
else if (links[i].innerHTML == "Web") {links[i].accessKey = "w";}
else if (links[i].innerHTML == "Images") {links[i].accessKey = "i";}
else if (links[i].innerHTML == "News") {links[i].accessKey = "n";}
else if (links[i].innerHTML == "Maps") {links[i].accessKey = "m";}
else if (links[i].innerHTML == "Groups") {links[i].accessKey = "g";}
else if (links[i].innerHTML == "Shopping") {links[i].accessKey = "p";}
else if (links[i].innerHTML == "Videos") {links[i].accessKey = "v";}
else if (links[i].lastChild.innerHTML == "Web") {links[i].accessKey = "w";}
else if (links[i].lastChild.innerHTML == "Images") {links[i].accessKey = "i";}
else if (links[i].lastChild.innerHTML == "News") {links[i].accessKey = "n";}
else if (links[i].lastChild.innerHTML == "Maps") {links[i].accessKey = "m";}
else if (links[i].lastChild.innerHTML == "Groups") {links[i].accessKey = "g";}
else if (links[i].lastChild.innerHTML == "Shopping") {links[i].accessKey = "p";}
else if (links[i].lastChild.innerHTML == "Videos") {links[i].accessKey = "v";}
else if (links[i].innerHTML == "Realtime") {links[i].accessKey = "r";}
//TODO Fix
else if (links[i].className == "gb3" ) {morelink = links[i];}
}
/* Just doodling around to see what would happen if I applied accesskeys to the sidebar instead...
var links = document.getElementById('ms').getElementsByTagName('li'); morelink=false;
for (i=0; i<links.length; i++) {
if (links[i].innerHTML == "Scholar") {links[i].accessKey = "s"; var scholar = links[i];}
else if (links[i].lastChild.innerHTML == "Web") {links[i].accessKey = "w";}
else if (links[i].lastChild.textContent == "Everything") {links[i].firstChild.accessKey = "w";}
else if (links[i].lastChild.textContent == "Images") {links[i].firstChild.accessKey = "i";}
else if (links[i].lastChild.textContent == "News") {links[i].firstChild.accessKey = "n";}
else if (links[i].lastChild.innerHTML == "News") {links[i].accessKey = "n";}
else if (links[i].lastChild.innerHTML == "Maps") {links[i].accessKey = "m";}
else if (links[i].lastChild.innerHTML == "Groups") {links[i].accessKey = "g";}
else if (links[i].lastChild.innerHTML == "Shopping") {links[i].accessKey = "p";}
else if (links[i].lastChild.innerHTML == "Videos") {links[i].accessKey = "v";}
else if (links[i].innerHTML == "Realtime") {links[i].accessKey = "r";}
//TODO Fix
else if (links[i].className == "gb3" ) {morelink = links[i];}
}
*/
// The code beneath this line adds the "Scholar Pro" and Wikipedia links.
// Delete everything from here down if you want rid of them!
if (morelink && typeof('morelink') != "undefined") {
//TODO Fix
//Wikipedia
wiki = document.createElement("a");
wiki.accessKey = ("d");
wiki.style.fontWeight = "normal";
wiki.className = "q";
wiki.innerHTML = "Wikipedia";
w = /\Wq=([^&]*)/;
if (window.location.href.match(w)) {
var wikisearch = w.exec(window.location.href);
wiki.href = "http://en.wikipedia.org/w/index.php?title=" + wikisearch[1];
} else {wiki.href = "http://en.wikipedia.org/wiki/Special:Search?fulltext=Search";}
space = document.createElement("span");
space.innerHTML = " ";
morelink.parentNode.insertBefore(wiki, morelink);
morelink.parentNode.insertBefore(space, morelink);
}
|
![]() ![]() |
One more update. Just thought I'd make the access keys for "Videos" and "Shopping" work on the old pages as well...
//TODO add j + k for next and previous pages
//TODO add a for advanced search
//TODO Consider adding access keys to GMail
var links = document.getElementsByTagName("a"); morelink=false;
for (i=0; i<links.length; i++) {
if (links[i].innerHTML == "Scholar") {links[i].accessKey = "s"; var scholar = links[i];}
//TODO Clean up
//Old code for older pages that do not have the new top menu bar layout
else if (links[i].innerHTML == "Web") {links[i].accessKey = "w";}
else if (links[i].innerHTML == "Images") {links[i].accessKey = "i";}
else if (links[i].innerHTML == "News") {links[i].accessKey = "n";}
else if (links[i].innerHTML == "Maps") {links[i].accessKey = "m";}
else if (links[i].innerHTML == "Groups") {links[i].accessKey = "g";}
else if (links[i].innerHTML == "Shopping") {links[i].accessKey = "p";}
else if (links[i].innerHTML == "Videos") {links[i].accessKey = "v";}
else if (links[i].lastChild.innerHTML == "Web") {links[i].accessKey = "w";}
else if (links[i].lastChild.innerHTML == "Images") {links[i].accessKey = "i";}
else if (links[i].lastChild.innerHTML == "News") {links[i].accessKey = "n";}
else if (links[i].lastChild.innerHTML == "Maps") {links[i].accessKey = "m";}
else if (links[i].lastChild.innerHTML == "Groups") {links[i].accessKey = "g";}
else if (links[i].lastChild.innerHTML == "Shopping") {links[i].accessKey = "p";}
else if (links[i].lastChild.innerHTML == "Videos") {links[i].accessKey = "v";}
else if (links[i].innerHTML == "Realtime") {links[i].accessKey = "r";}
//TODO Fix
else if (links[i].className == "gb3" ) {morelink = links[i];}
}
/* Just doodling around to see what would happen if I applied accesskeys to the sidebar instead...
var links = document.getElementById('ms').getElementsByTagName('li'); morelink=false;
for (i=0; i<links.length; i++) {
if (links[i].innerHTML == "Scholar") {links[i].accessKey = "s"; var scholar = links[i];}
else if (links[i].lastChild.innerHTML == "Web") {links[i].accessKey = "w";}
else if (links[i].lastChild.textContent == "Everything") {links[i].firstChild.accessKey = "w";}
else if (links[i].lastChild.textContent == "Images") {links[i].firstChild.accessKey = "i";}
else if (links[i].lastChild.textContent == "News") {links[i].firstChild.accessKey = "n";}
else if (links[i].lastChild.innerHTML == "News") {links[i].accessKey = "n";}
else if (links[i].lastChild.innerHTML == "Maps") {links[i].accessKey = "m";}
else if (links[i].lastChild.innerHTML == "Groups") {links[i].accessKey = "g";}
else if (links[i].lastChild.innerHTML == "Shopping") {links[i].accessKey = "p";}
else if (links[i].lastChild.innerHTML == "Videos") {links[i].accessKey = "v";}
else if (links[i].innerHTML == "Realtime") {links[i].accessKey = "r";}
//TODO Fix
else if (links[i].className == "gb3" ) {morelink = links[i];}
}
*/
// The code beneath this line adds the "Scholar Pro" and Wikipedia links.
// Delete everything from here down if you want rid of them!
if (morelink && typeof('morelink') != "undefined") {
//TODO Fix
//Wikipedia
wiki = document.createElement("a");
wiki.accessKey = ("d");
wiki.style.fontWeight = "normal";
wiki.className = "q";
wiki.innerHTML = "Wikipedia";
w = /\Wq=([^&]*)/;
if (window.location.href.match(w)) {
var wikisearch = w.exec(window.location.href);
wiki.href = "http://en.wikipedia.org/w/index.php?title=" + wikisearch[1];
} else {wiki.href = "http://en.wikipedia.org/wiki/Special:Search?fulltext=Search";}
space = document.createElement("span");
space.innerHTML = " ";
morelink.parentNode.insertBefore(wiki, morelink);
morelink.parentNode.insertBefore(space, morelink);
}
|


