Qwerjk

Building nothing, laying bricks

Update: Sorry guys, the game is up. Gmail has now moved 100% to the new look

If you prefer the old gmail interface, you can keep it a little while longer. The settings menu option to revert to the old look is still around, only hidden. Run the script below to bring it back.

Run as a bookmarklet

Drag it to your bookmarks toolbar, refresh gmail, and click

revert gmail

you really should look over the source first

Run in the console

Refresh gmail and paste the code below into the console

(function(){
  function search(root, matchers, maxDepth, depth){
    depth = depth||0;
    maxDepth = maxDepth||matchers.length;
  
    if(depth == maxDepth) return [root];
  
    for(var key in root){ 
      try{
        if(root[key] !== root && (!matchers[depth] || matchers[depth](key, root[key]))){ 
          var path = search(root[key], matchers, maxDepth, depth+1); 
          if(path){ 
            return [key].concat(path);
          }
        }
      }catch(e){}
    } 
  }

  function searchDom(root, match){
    if(match(root)) return root;
    var child = root.firstChild;
    while(child){
      var found = searchDom(child, match);
      if(found) return found;
      child = child.nextSibling;
    }
  }
  var settingsEl = searchDom(frames[3].document.body, function(el){ 
    return (el instanceof frames[3].HTMLDivElement) && el.getAttribute("title") == "Settings"
  });

  if(settingsEl){
    console.log("Settings element found:", settingsEl);
    if(settingsEl.getAttribute("aria-owns")){
      alert("Run this script before clicking the settings menu. Refresh the page and try again"); 
      return;
    }
  }else{
    alert("Reversion failed. Couldn't find settings menu element.");
    return;
  }

  var settingsParent = settingsEl.parentElement;

  var root = frames[0];
  var path = search(root, [
      null, 
      function(k,v){ return v && v.src == settingsParent}, 
      function(k,v){ return typeof(v) === "object"}, 
      function(k,v){ return v == settingsParent}]);

  if(!path){
    alert("Reversion failed. Couldn't find settings object");
    return;
  }

  console.log("Path found:", path);
  var settings = root;
  for(var i=0; i<3; i++){
    settings = settings[path[i]];
  }

  console.log("Settings found:", settings);
  console.log("Oa:", settings.Oa);
  if(settings.Oa === false){
    settings.Oa = true;
    alert('Settings menu updated. Click "revert to old look temporarily" in the settings menu to complete.');
  }else{
    for(var k in settings){
      if(settings[k] === false){
        settings[k] = true;
        break;
      }
    }
    alert('Settings menu probably updated. Click "revert to old look temporarily" in the settings menu to complete.');
  }
  return void(0);
  
})();

blog comments powered by Disqus