GMX standalone view

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

目前为 2020-07-20 提交的版本。查看 最新版本

  1. // ==UserScript==
  2. // @name GMX standalone view
  3. // @name:de GMX Standalone-Ansicht
  4. // @name:fr GMX email - fenêtre séparée
  5. // @namespace https://github.com/Procyon-b
  6. // @version 0.6.1
  7. // @description Set option to open email in standalone window (gmx / web.de)
  8. // @description:de Stellen Sie die Option so ein, dass E-Mails im eigenständigen Fenster geöffnet werden (gmx / web.de)
  9. // @description:fr Réactiver l'ouverture des emails dans une fenêtre popup (gmx / web.de)
  10. // @author Achernar
  11. // @match https://3c.gmx.net/mail/client/*
  12. // @match https://3c-bap.gmx.net/mail/client/*
  13. // @include https://3c-bs.gmx.tld/mail/client/*
  14. // @match https://3c.web.de/mail/client/*
  15. // @match https://3c-bap.web.de/mail/client/*
  16. // @run-at document-body
  17. // @grant GM_setValue
  18. // @grant GM_getValue
  19. // ==/UserScript==
  20.  
  21. (function() {
  22. "use strict";
  23.  
  24. if ( /^\/mail\/client\/(home|folder|search)/.test(location.pathname) ) {
  25.  
  26. const maxRetry=40;
  27. var e, r, retry=maxRetry;
  28.  
  29. function toggle(ev) {
  30. if (!e) return;
  31. var v=(typeof ev == 'object')? !phx.vars.enableStandaloneView : ev;
  32. e.checked=v;
  33. phx.vars.enableStandaloneView=v;
  34. try{
  35. GM_setValue('option', v);
  36. }catch(er){
  37. window.sessionStorage._popup_=v;
  38. }
  39. }
  40.  
  41.  
  42. function addChk() {
  43. if (!(r=document.querySelector('.widget.menubar .button-container.left'))) {
  44. if (retry--) {
  45. setTimeout(addChk,10);
  46. }
  47. return;
  48. }
  49. retry=maxRetry;
  50. e=document.createElement('input');
  51. e.type='checkbox';
  52. e.id='standaloneView';
  53. e.title='Standalone view';
  54. e.style='margin-top: 6px;';
  55. r.appendChild(e);
  56. e.onclick=toggle;
  57. try{
  58. toggle(GM_getValue('option',true));
  59. }catch(er){
  60. let v=window.sessionStorage._popup_;
  61. if (v === undefined) v=true;
  62. else v=JSON.parse(v);
  63. toggle(v);
  64. }
  65. }
  66.  
  67. addChk();
  68.  
  69. const obs = new MutationObserver(function(mutL){
  70. for (let mut of mutL) {
  71. for (let el of mut.addedNodes) {
  72. if (el.classList && el.classList.contains('menubar')) {
  73. r=document.querySelector('.widget.menubar .button-container.left');
  74. addChk();
  75. return;
  76. }
  77. }
  78. }
  79. });
  80.  
  81. var t=document.querySelector('#panel-mail-table .panel-body form');
  82. if (t) {
  83. obs.observe(t, {subtree: false, childList: true, attributes: false} );
  84. t.addEventListener('click', function(ev){
  85. if (ev.target.classList.contains('mail-open')) {
  86. if (phx.vars.enableStandaloneView) {
  87. ev.stopPropagation();
  88. let mId=ev.target.closest('tr[data-oao-mailid]');
  89. let u=location.origin+location.pathname.replace(/^.*?;/, '/mail/client/mail/detail;')
  90. + '?mailId='+mId.attributes['data-oao-mailid'].value+'&folderId='+mId.attributes['data-folderid'].value+'&standalone=true';
  91. let w=Math.min( Math.max(1024, t.scrollWidth) ,1400);
  92. window.open(u, mId.attributes['data-oao-mailid'].value ,'width='+w+',height=600');
  93. }
  94. }
  95. },
  96. {capture: true} );
  97. }
  98.  
  99. }
  100.  
  101. if (location.href.endsWith('&standalone=true')) {
  102. let st=document.createElement('style');
  103. st.innerText='#navigation, #section-0, .section-1 .prev, .section-1 .next, .section-1 .menubar, .ad {display: none;} .section-1 {left: 0;} .mail-display-wrapper {top: 0;} html.can-have-sky .section-content {margin-right: 0 !important;} .section-1 > .section-container {bottom:0 !important;}';
  104. (document.head || document.documentElement).appendChild(st);
  105. var t=document.body.querySelector('.section-1 [data-webdriver="MailDetail:Close"]');
  106. if (t) t.addEventListener('click', function(ev){window.close();}, {capture: true});
  107. document.body.addEventListener('keydown', function(ev){
  108. ev.stopPropagation();
  109. });
  110. }
  111.  
  112. })();