Gmail conversation view toggle bookmarketlet / favelet / “scriptlet”

大兔子大兔子 提交于 2019-11-30 11:18:01
seahorsepip

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);

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.

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!

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)

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!