GMX standalone view

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

目前为 2020-08-11 提交的版本。查看 最新版本

// ==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.5
// @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\/[^;]+;/,'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.querySelector('.section-1 .mail-subject dd');
      if (t) {
        document.title=document.title.split('-')[0]+' - '+t.innerText;
        t=document.querySelector('#fullscreen');
        t && t.addEventListener('click', function(ev){
          window.close();
          }, {capture: true});
        }
      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);
  }

})();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址