Hack #64. Add a Delete Button to Gmail
Improve the Gmail interface with the most requested feature that Google doesn't want you to have.
Many netizens have gotten a Gmail account and been wowed with the interface, but noticed one critical missing piece: there is no easy way to delete a message. Deletion in the standard Gmail interface requires opening the drop-down actions box and selecting the last item, which is cumbersome for a frequent activity.
This hack alters the user interface of Gmail to include an extra button that lets the user delete any message with one simple click.
The Code
This script is split into five parts.
The
_gd_gmail_delete
function performs the actual message deletion. It simply searches for a<select>
element within its parent container and then finds the appropriate action within that menu. If it is found, the script triggers theonchange
handler of the select box, which launches the standard Gmail code to delete the selected messages.The
_gd_make_dom_button
function is notable because it supports multiple languages. There is only one word that the script adds, but this function attempts to autodetect the language in the Gmail interface, and sets the Delete button caption to the proper translation. It also attaches the_gd_gmail_delete
function as theonclick
event handler for the button.The
_gd_insert_button
function does the real magic in this script. It calls the_gd_make_dom_button
function to create a new element to be injected into the page, does a little ...
Get Greasemonkey Hacks now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.