GMX standalone view

Set option to open email in standalone window (gmx / web.de)

当前为 2020-08-09 提交的版本,查看 最新版本

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         GMX standalone view
// @name:de      GMX Standalone-Ansicht
// @name:fr      GMX email - fenêtre séparée
// @namespace    https://github.com/Procyon-b
// @version      0.6.4
// @description  Set option to open email in standalone window (gmx / web.de)
// @description:de Stellen Sie die Option so ein, dass E-Mails im eigenständigen Fenster geöffnet werden (gmx / web.de)
// @description:fr Réactiver l'ouverture des emails dans une fenêtre popup (gmx / web.de)
// @author       Achernar
// @match        https://3c.gmx.net/mail/client/*
// @match        https://3c-bap.gmx.net/mail/client/*
// @include      https://3c-bs.gmx.tld/mail/client/*
// @match        https://3c.web.de/mail/client/*
// @match        https://3c-bap.web.de/mail/client/*
// @run-at document-start
// @grant GM_setValue
// @grant GM_getValue
// ==/UserScript==

(function() {
"use strict";

if ( /^\/mail\/client\/(home|folder|search)/.test(location.pathname) ) document.addEventListener('DOMContentLoaded', function(){
  const maxRetry=40;
  var e, r, retry=maxRetry;

  function toggle(ev) {
    if (!e) return;
    var v=(typeof ev == 'object')? !phx.vars.enableStandaloneView : ev;
    e.checked=v;
    phx.vars.enableStandaloneView=v;
    try{
      GM_setValue('option', v);
    }catch(er){
      window.sessionStorage._popup_=v;
      }
  }

  function addChk() {
    if (!(r=document.querySelector('.widget.menubar .button-container.left'))) {
      if (retry--) {
        setTimeout(addChk,10);
        }
      return;
      }
    retry=maxRetry;
    e=document.createElement('input');
    e.type='checkbox';
    e.id='standaloneView';
    e.title='Standalone view';
    e.style='margin-top: 6px;';
    r.appendChild(e);
    e.onclick=toggle;
    try{
      toggle(GM_getValue('option',true));
    }catch(er){
      let v=window.sessionStorage._popup_;
      if (v === undefined) v=true;
      else v=JSON.parse(v);
      toggle(v);
      }
  }

  addChk();

  const obs = new MutationObserver(function(mutL){
    for (let mut of mutL) {
      for (let el of mut.addedNodes) {
        if (el.classList && el.classList.contains('menubar')) {
          r=document.querySelector('.widget.menubar .button-container.left');
          addChk();
          return;
          }
        }
      }
    });

  var t=document.querySelector('#panel-mail-table .panel-body form');
  if (t) {
    obs.observe(t, {subtree: false, childList: true, attributes: false} );
    t.addEventListener('click', function(ev){
      if (ev.target.classList.contains('mail-open')) {
        if (phx.vars.enableStandaloneView) {
          ev.stopPropagation();
          let mId=ev.target.closest('tr[data-oao-mailid]');
          let u=location.origin+location.pathname.replace('search/mail;','folder;')+'?folderId='+mId.attributes['data-folderid'].value+'#';
          let w=Math.min( Math.max(1024, t.scrollWidth) ,1400);
          window.open(u, mId.attributes['data-oao-mailid'].value ,'width='+w+',height=600');
          }
        }
      },
      {capture: true} );
    }

});

if (window.name && (window.name.length==20) && window.name.startsWith('tmai') ) {
  let h='#action/mailDisplay/mailId/'+window.name+'/page/0';

  window.onhashchange=function(){
    if (location.href.includes('#') && (location.hash != h) ) location.hash=h;
    }

  if (location.href.includes('#')) {
    location.hash='#';
    location.hash=h;
    }

  let st=document.createElement('style');
  st.innerText='#navigation, #section-0, .section-1 .prev, .section-1 .next, .section-1 .menubar, .ad, div#mail-instant-reply, #maillist, #selectionCountMessage {display: none !important;} .section-1 {left: 0 !important;} .mail-display-wrapper {top: 0 !important;left: 0 !important;} html.can-have-sky .section-content {margin-right: 0 !important;} .section-1 > .section-container {bottom:0 !important;} div#system-message > div {display: block !important}';
  (document.head || document.documentElement).appendChild(st);

  function ready(){
    let c=-20;
    function setTitle() {
      let t=document.body.querySelector('.section-1 .mail-subject dd');
      if (t) document.title=document.title.split('-')[0]+' - '+t.innerText;
      else c++ && setTimeout(setTitle, 100);
      }
    setTitle();
    document.body.addEventListener('click', function(ev){
      if (ev.target.id=='fullscreen') window.close();
      }, {capture: true});

    document.body.addEventListener('keydown', function(ev){
      ev.stopPropagation();
      });
    }

  if (document.readyState != 'loading') ready();
  else document.addEventListener('DOMContentLoaded', ready);
  }

})();