Yesterday Box: Creating and Launching URL with Today's Date via Javascript Bookmarklet

Is it possible to create a simple bookmarklet that generates a URL with the current date and opens it automatically in the browser?

This feature could be useful for creating URLs for prefilled forms or implementing something like yesterbox for web-based email clients such as Gmail.

Let's try making one for the first logged-in user on Gmail, here is an example URL with the date included:

https://mail.google.com/mail/u/0/#search/is%3Ainbox+before%3A2016-08-31
# or "priority inbox"
https://mail.google.com/mail/u/0/#search/is%3Ainbox+is%3Aimportant+before%3A2016-08-31

Answer №1

Discover a helpful bookmarklet that enhances your Gmail search experience! By adding "+before:date" to the current URL, you can easily filter emails based on specific dates. For instance, you can create a yesterbox by appending this query to your search. Just be cautious with "label:X" queries as they modify the URL structure differently.

/* Improve Your Gmail Search View with Current Date Filter */
javascript:(function(){ var d=new Date(); var curr=location.href; location.replace(curr+'+before:'+d.getFullYear()+'-'+(d.getMonth()+1)+'-'+d.getDate()); })(); /* Source: http://stackoverflow.com/a/29808878 */

Use this bookmarklet to open a new tab or window with the date filter set to today:

javascript:(function(){ var d=new Date(); window.open('https://mail.google.com/mail/u/0/#search/is:inbox+before:'+d.getFullYear()+'-'+(d.getMonth()+1)+'-'+d.getDate()); })();

You can also include criteria like "is:important" or "is:unimportant" for more refined searches:

javascript:(function(){ var d=new Date(); window.open('https://mail.google.com/mail/u/0/#search/is:inbox+is:important+before:'+d.getFullYear()+'-'+(d.getMonth()+1)+'-'+d.getDate()); })();

javascript:(function(){ var d=new Date(); window.open('https://mail.google.com/mail/u/0/#search/is:inbox+is:unimportant+before:'+d.getFullYear()+'-'+(d.getMonth()+1)+'-'+d.getDate()); })();

For those who prefer to open results in the current tab/window, here are alternative versions:

javascript:(function(){ var d=new Date(); location.replace('https://mail.google.com/mail/u/0/#search/is:inbox+is:unimportant+before:'+d.getFullYear()+'-'+(d.getMonth()+1)+'-'+d.getDate()); })(); /* Source: http://stackoverflow.com/a/29808878 */

javascript:(function(){ var d=new Date(); location.replace('https://mail.google.com/mail/u/0/#search/is%3Ainbox+is%3Aimportant+before:'+d.getFullYear()+'-'+(d.getMonth()+1)+'-'+d.getDate()); })(); /* Source: http://stackoverflow.com/a/29808878 */

Additionally, you can add the "starred" criterion to your searches:

javascript:(function(){ var d=new Date(); location.replace('https://mail.google.com/mail/u/0/#search/is:inbox+is:unimportant+-is:starred+before:'+d.getFullYear()+'-'+(d.getMonth()+1)+'-'+d.getDate()); })(); /* Source: http://stackoverflow.com/a/29808878 */

javascript:(function(){ var d=new Date(); location.replace('https://mail.google.com/mail/u/0/#search/is%3Ainbox+(is%3Aimportant+OR+is%3Astarred)+before:'+d.getFullYear()+'-'+(d.getMonth()+1)+'-'+d.getDate()); })(); /* Source: http://stackoverflow.com/a/29808878 */

Explore more about JavaScript bookmarklets at

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

How to dynamically load a file based on the chosen option value in React

Two select textboxes on my page are named Choose City and Choose District. I also have some files related to cities and districts: // cities.js const cities = { "01": { "name": "City 1", "code": "01" }, ...

React Bootstrap always displays tooltips

I have integrated react-bootstrap into my project. I am currently attempting to keep a tooltip always displayed, but I am facing some challenges in achieving this. Below are the approaches I have tried so far: <Card style={{width: '10rem'}} ...

Running two different wdio.config.js files consecutively

Is it possible to run two wdio.config.js files with different configurations, one after another? Here is how the first configuration file is defined in the code: const { join } = require('path'); require('@babel/register') exports.co ...

Passing a click event to a reusable component in Angular 2 for enhanced functionality

I am currently working on abstracting out a table that is used by several components. While most of my dynamic table population needs have been met, I am facing a challenge with making the rows clickable in one instance of the table. Previously, I simply ...

Only the initial value is being processed in the for loop using Javascript

I am having issues trying to sum the values within a for loop sourced from my Django database using JavaScript. Currently, when I iterate through the loop, only the first value in the array is returned. I need assistance in finding a solution that allows ...

Tips for passing props while clicking on a v-data-table:

I am currently facing an issue in my app while using v-data-table. I am able to pass props with an extra slot, but I want the entire row to be clickable in order to open a dialog with the prop item: <template v-slot:item.actions="{ item }"> ...

Is there a way to implement word wrapping in li text without making any changes to its width

Is there a method to wrap the content inside li elements without modifying their width? As an illustration, consider the following structure - <ul> <li>Text Example</li> <li>Text Example</li> <li>Text Exampl ...

Including a unicode escape sequence in a variable string value

I'm struggling to find the right way to include a unicode escape in a dynamic string value to display emojis in React. My database stores the hexcode for the emoji (1f44d) I have set up a styled-component with the necessary css for rendering an emoj ...

Updating the state of an object nested within another object in React JS

So, I have a nested object within another object and I need to update the state of one or more properties in the inner object. This is my current state: const [products, setProducts] = useState({ name: '', type: '', price: '& ...

The React component continuously refreshes whenever the screen is resized or a different tab is opened

I've encountered a bizarre issue on my portfolio site where a diagonal circle is generated every few seconds. The problem arises when I minimize the window or switch tabs, and upon returning, multiple circles populate the screen simultaneously. This b ...

How can I design an avatar image within a button similar to Facebook's style?

I'm currently working on a project that involves adding an avatar and a dropdown menu for account settings to my navigation bar. I've already created the dropdown, but I'm having trouble styling the avatar within the button. The button is ta ...

How can you utilize data captured through a JavaScript onchange event in conjunction with another event?

Is there a way to utilize the firmType data captured during event 1 in event 2? code event 1 $("body").on("change","#so_customer", function(v){ customerFirm = $(this).find(":selected").data("employer"); $("#customer_employer").val(cust ...

Resolving the Table Issue with 'onclick' in Javascript

Apologies for the lack of creativity in the title, I struggled to come up with something fitting. Currently, I am engaged in the development of a user-friendly WYSIWYG site builder. However, I have encountered an obstacle along the way. I've devised ...

Vuejs allows objects to trigger the execution of methods through elements

My goal is to utilize a function in order to individually set the content of table cells. In this specific scenario, I aim to enclose the status with the <strong> - Tag (I refrain from modifying the template directly because it is stored within a com ...

Discover multiple keys within a new Map object

Our usual approach involves creating a new Map like this: const hash = new Map() hash.set(key,value) To retrieve the information, we simply use: hash.get(specificKey) An advantage of using Map is that we have flexibility in choosing keys and values. Cur ...

Creating a URL using Form Fields with Javascript or jQuery - Reg

Creating a Custom URL with Form Fields using JavaScript or jQuery I am looking to generate an external link by incorporating a form with a dynamic variable as shown below: (Where 2500 can be customized based on user input) The final URL will be display ...

Discovering more about this topic

Looking for a way to create an expandable box that enlarges when "read more" is clicked, revealing text below it. And also looking to add a button that closes the expanded text back up. Experimented with the toggletext JavaScript command, as found on this ...

What are the consequences of submitting a form to a different website through POST method?

Dealing with a CMS that does not offer an easy way to add a NodeJS route for handling form data can be quite challenging. I'm considering the following setup - would this be considered bad practice or unsafe? Server 1 (Ghost CMS) : www.domain.com &l ...

Is there a way to handle the ajax request only when necessary, instead of processing it every few seconds?

Currently, I am working on an AJAX chat system using PHP, MySQL, JavaScript, and AJAX. I have a piece of code that retrieves all chat messages within a div using AJAX, with the function running every 2 seconds. My issue lies in the fact that the div autom ...

Using getJSON to return key/value pair from local host URL in JSFiddle - A step-by-step guide

After following a tutorial on building an API using Python, Flask, SQLite, and SQLAlchemy, I have successfully tested the connection by hitting the localhost address in my browser. Now, I am curious if it is possible to test this connection and see the des ...