16

I noticed that if I have a gmail tab open with conversation view on/off, and then I open another tab and change the conversation view setting, my original tab stays in the conversation view state it started in such as when doing new searches etc. and the new tab uses the setting I just changed it to.

This led me to think there might be some JavaScript bookmarklet / favelet / "scriptlet" that could easily let us change the setting for a given gmail tab temporarily without having to go into the settings.

Does anyone know of this already in existence or is anyone able to create it? My thought would be to capture a load of gmail with it on and with it off and do a diff / winmerge on the two to see what's different and take it from there, but I'm hoping someone's already created it =).

sa289
  • 700
  • 3
  • 12

4 Answers4

9

I'll look into the gmail js and make a bookmarklet :P

Edit: seems the js is obfuscated A lot, copying the function from the original js is gonna be hard...

I'll check what the html changes are between both views and write a js function myself to apply those changes.

I went and instead made it a bit different, I wrote some js that does actually the thing that you would do yourself(it simulates going to settings and changing them).

I made a jsfiddle with a link that can be dragged into the bookmarks bar:

https://jsfiddle.net/randomengineer/0nc4hajp/4/

The bookmarklet code:

javascript:
window.location.hash = 'settings/general';
a = () => document.querySelector('tbody tr:nth-child(13) input:not(:checked)');
b = setInterval(() => {
    if(a() != null) {
        clearInterval(b);
        a().click();
        document.querySelector('[guidedhelpid=save_changes_button]').click();
    }
}, 5);
Jeff Axelrod
  • 27,676
  • 31
  • 147
  • 246
seahorsepip
  • 4,519
  • 1
  • 19
  • 30
  • I like bounties haha – seahorsepip Feb 08 '16 at 19:28
  • This is brilliant. Thanks seahorsepip. There has been a thread on the google suggest-a-labs feature request forum for like 4 years, and you just went and did it with like 2 lines of javascript. Bravo. – danielpops Apr 25 '16 at 21:38
  • This is not working for me ... just takes me to the settings page. Did G break it? is there any other solution? – Dan May 11 '16 at 17:19
  • @Ze'ev Might be because of slow internet taking longer then 1second(1000ms), increase the number 1000 to a higher value till it works. – seahorsepip May 12 '16 at 00:07
  • 2
    In my gmail I needed to edit the first selector to "tbody tr:nth-child(8) table input:not(:checked)" - I don't know if this is specific to my account or because of a change in gmail's settings but might be useful for someone else – cfogelberg May 29 '17 at 18:34
  • @cfogelberg A lot can change in a year time and google loves A/B testing so above code will always never be 100% accurate. – seahorsepip May 29 '17 at 22:00
  • 1
    I had to change the first selector to ".AO tbody tr:nth-child(8) table input:not(:checked)" in case that helps anybody. – pvans Aug 03 '17 at 22:23
  • This works to toggle on/off, in whatever is the current account: `javascript:window.location.href="https://mail.google.com"+window.location.pathname+"#settings/general";sBase="div.AO table tbody tr:nth-child(8) table:nth-of-type(";sOn=sBase+"1) input";sOff=sBase+"2) input";setTimeout(function(){if(document.querySelector(sOff).checked) document.querySelector(sOn).click();else document.querySelector(sOff).click();document.querySelector("[guidedhelpid=save_changes_button]").click()},1000);` – Dan Mar 09 '18 at 17:38
  • Just fixed bookmarklet as of today (needed to bump 8th settings table row to 13th to fix) https://jsfiddle.net/randomengineer/0nc4hajp/4/ – Jeff Axelrod May 02 '19 at 15:28
3

Saved settings are just to reload the JS code in the way you prefer, so you are correct it can be made easy to change. seahorsepip did a good one on it, if you need a custom grease script to install to your chrome i would be glad to help.

1

Love the solution by seahorsepip. I combined it with the "Shortcut Manager" Chrome extension (http://www.makeuseof.com/tag/shortcut-manager-assign-hotkeys-to-various-browser-actions-chrome/) and now I can toggle with a keyboard shortcut!

0

New solution for 2019 (see Bookmarklet in JavaScript to toggle Gmail conversation view).

This will toggle the current state On/Off and Save:

window.location.href = "https://mail.google.com"+window.location.pathname+"#settings/general";
setTimeout(function() {
    convTogs = document.getElementsByName("bx_vmb");
    if (convTogs[0].checked) convTogs[1].click(); 
    else convTogs[0].click();
    document.querySelector("[guidedhelpid=save_changes_button]").click();
}, 2000);

(Thanks, @Zenoo!)

Note: If you have multiple Gmail accounts open (like me) this will work in your current window (unlike https://mail.google.com/mail/u/0/#settings/general which will go to your default account)

Dan
  • 1,257
  • 2
  • 15
  • 31