GMX standalone view

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

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

  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.5
  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-start
  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) ) document.addEventListener('DOMContentLoaded', function(){
  25. const maxRetry=40;
  26. var e, r, retry=maxRetry;
  27.  
  28. function toggle(ev) {
  29. if (!e) return;
  30. var v=(typeof ev == 'object')? !phx.vars.enableStandaloneView : ev;
  31. e.checked=v;
  32. phx.vars.enableStandaloneView=v;
  33. try{
  34. GM_setValue('option', v);
  35. }catch(er){
  36. window.sessionStorage._popup_=v;
  37. }
  38. }
  39.  
  40. function addChk() {
  41. if (!(r=document.querySelector('.widget.menubar .button-container.left'))) {
  42. if (retry--) {
  43. setTimeout(addChk,10);
  44. }
  45. return;
  46. }
  47. retry=maxRetry;
  48. e=document.createElement('input');
  49. e.type='checkbox';
  50. e.id='standaloneView';
  51. e.title='Standalone view';
  52. e.style='margin-top: 6px;';
  53. r.appendChild(e);
  54. e.onclick=toggle;
  55. try{
  56. toggle(GM_getValue('option',true));
  57. }catch(er){
  58. let v=window.sessionStorage._popup_;
  59. if (v === undefined) v=true;
  60. else v=JSON.parse(v);
  61. toggle(v);
  62. }
  63. }
  64.  
  65. addChk();
  66.  
  67. const obs = new MutationObserver(function(mutL){
  68. for (let mut of mutL) {
  69. for (let el of mut.addedNodes) {
  70. if (el.classList && el.classList.contains('menubar')) {
  71. r=document.querySelector('.widget.menubar .button-container.left');
  72. addChk();
  73. return;
  74. }
  75. }
  76. }
  77. });
  78.  
  79. var t=document.querySelector('#panel-mail-table .panel-body form');
  80. if (t) {
  81. obs.observe(t, {subtree: false, childList: true, attributes: false} );
  82. t.addEventListener('click', function(ev){
  83. if (ev.target.classList.contains('mail-open')) {
  84. if (phx.vars.enableStandaloneView) {
  85. ev.stopPropagation();
  86. let mId=ev.target.closest('tr[data-oao-mailid]');
  87. let u=location.origin+location.pathname.replace(/search\/[^;]+;/,'folder;')+'?folderId='+mId.attributes['data-folderid'].value+'#';
  88. let w=Math.min( Math.max(1024, t.scrollWidth) ,1400);
  89. window.open(u, mId.attributes['data-oao-mailid'].value ,'width='+w+',height=600');
  90. }
  91. }
  92. },
  93. {capture: true} );
  94. }
  95.  
  96. });
  97.  
  98. if (window.name && (window.name.length==20) && window.name.startsWith('tmai') ) {
  99. let h='#action/mailDisplay/mailId/'+window.name+'/page/0';
  100.  
  101. window.onhashchange=function(){
  102. if (location.href.includes('#') && (location.hash != h) ) location.hash=h;
  103. }
  104.  
  105. if (location.href.includes('#')) {
  106. location.hash='#';
  107. location.hash=h;
  108. }
  109.  
  110. let st=document.createElement('style');
  111. 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}';
  112. (document.head || document.documentElement).appendChild(st);
  113.  
  114. function ready(){
  115. let c=-20;
  116. function setTitle() {
  117. let t=document.querySelector('.section-1 .mail-subject dd');
  118. if (t) {
  119. document.title=document.title.split('-')[0]+' - '+t.innerText;
  120. t=document.querySelector('#fullscreen');
  121. t && t.addEventListener('click', function(ev){
  122. window.close();
  123. }, {capture: true});
  124. }
  125. else c++ && setTimeout(setTitle, 100);
  126. }
  127. setTitle();
  128. document.body.addEventListener('click', function(ev){
  129. if (ev.target.id=='fullscreen') window.close();
  130. }, {capture: true});
  131.  
  132. document.body.addEventListener('keydown', function(ev){
  133. ev.stopPropagation();
  134. });
  135. }
  136.  
  137. if (document.readyState != 'loading') ready();
  138. else document.addEventListener('DOMContentLoaded', ready);
  139. }
  140.  
  141. })();