PV Forum

Anpassungen für das PV Forum

  1. // ==UserScript==
  2. // @name PV Forum
  3. // @namespace https://gf.qytechs.cn/users/156194
  4. // @version 1.0
  5. // @description Anpassungen für das PV Forum
  6. // @author rabe85
  7. // @match https://www.photovoltaikforum.com/*
  8. // @icon https://www.google.com/s2/favicons?sz=64&domain=photovoltaikforum.com
  9. // @license MIT
  10. // @grant GM_setValue
  11. // @grant GM_getValue
  12. // ==/UserScript==
  13.  
  14. // Todo:
  15. // - Doppelter Klick nach Herabscrollen mit offenem Usermenü nötig, um es wieder zu öffnen
  16.  
  17. (function() {
  18. 'use strict';
  19.  
  20. function pv_forum() {
  21.  
  22. // Funktion - Header nur beim Hochscrollen oben am Rand anzeigen
  23. var sticky_header_scroll_position_old = 0;
  24. function sticky_header_scroll() {
  25. var sticky_header_scroll_position = document.documentElement.scrollTop;
  26. if(sticky_header_scroll_position < sticky_header_scroll_position_old) {
  27. document.getElementsByClassName('pageHeaderPanel')[0].setAttribute('style','position: fixed;top: 0px;width: 100%;z-index: 23585;');
  28. } else {
  29. document.getElementsByClassName('pageHeaderPanel')[0].setAttribute('style','position: absolute;');
  30. var usermenu_close0 = document.getElementsByClassName('userMenu');
  31. for(var umc = 0, usermenu_close; !!(usermenu_close=usermenu_close0[umc]); umc++) {
  32. usermenu_close.setAttribute('hidden','');
  33. }
  34. }
  35. sticky_header_scroll_position_old = sticky_header_scroll_position;
  36. }
  37.  
  38. //Funktion - Usermenü bei normalem Header beim Herunterscrollen schließen
  39. function header_scroll_normal() {
  40. var header_scroll_position_normal = document.documentElement.scrollTop;
  41. if(header_scroll_position_normal > sticky_header_scroll_position_old) {
  42. var usermenu_close_normal0 = document.getElementsByClassName('userMenu');
  43. for(var umcn = 0, usermenu_close_normal; !!(usermenu_close_normal=usermenu_close_normal0[umcn]); umcn++) {
  44. usermenu_close_normal.setAttribute('hidden','');
  45. }
  46. }
  47. }
  48.  
  49. // Headerfunktion auswählen
  50. var header_auswahl = GM_getValue('header_auswahl', 'normal');
  51. var header_auswahl_text = 'Kopfzeile: Normal';
  52. var header_auswahl_status = 'fixed';
  53.  
  54. switch(header_auswahl) {
  55. case 'fixed': // Header immer fest oben am Rand anzeigen
  56. document.getElementsByClassName('pageHeaderPanel')[0].setAttribute('style','position: fixed;top: 0px;width: 100%;z-index: 23585;');
  57. header_auswahl_text = 'Kopfzeile: Fixiert';
  58. header_auswahl_status = 'scroll';
  59. break;
  60. case 'scroll': // Header nur beim Hochscrollen oben am Rand anzeigen
  61. document.addEventListener("scroll", sticky_header_scroll, false);
  62. header_auswahl_text = 'Kopfzeile: Hochscrollen';
  63. header_auswahl_status = 'normal';
  64. break;
  65. default: // Header normal anzeigen
  66. document.getElementsByClassName('pageHeaderPanel')[0].setAttribute('style','position: absolute;');
  67. document.addEventListener("scroll", header_scroll_normal, false);
  68. }
  69. var usermenu = document.getElementsByClassName('userMenu userMenuControlPanel')[0];
  70. if (usermenu) {
  71. usermenu.getElementsByClassName('userMenuContent')[1].insertAdjacentHTML('afterend', '<div class="userMenuItem userMenuItemNarrow userMenuItemSingleLine"><div class="userMenuItemImage"><fa-icon size="16" name="minus" solid="" aria-hidden="true" translate="no"></fa-icon></div><div class="userMenuItemContent"><a id="header_auswahl_menu" data-status="' + header_auswahl_status + '" title="Klicken zum Wechseln zwischen Normal, Fixiert und Hochscrollen" style="cursor: pointer;color: inherit;">' + header_auswahl_text + '</a></div></div>');
  72. }
  73. function header_auswahl_speichern() {
  74. if(header_auswahl != document.getElementById('header_auswahl_menu').dataset.status) { GM_setValue('header_auswahl', document.getElementById('header_auswahl_menu').dataset.status); }
  75. //window.scrollTo(0, 0);
  76. location.reload();
  77. }
  78. document.getElementById('header_auswahl_menu').addEventListener("click", header_auswahl_speichern, false);
  79.  
  80. // Werbung ausblenden
  81. var ad_thread0 = document.querySelectorAll('.wcfAdLocation, .wcfAdLocationHeaderContent, .wbbAdLocationIn1stPost, #ad_position_box, div[id^="google_ads_iframe"], iframe[name^="goog_topics_frame"], img[src^="https://ad-delivery.net/"], img[src^="https://ad.doubleclick.net/"], img[id^="adg-"], iframe[id^="adg-"], div[id^="adunit"], .symplr-ad-holder');
  82. for(var adt = 0, ad_thread; !!(ad_thread=ad_thread0[adt]); adt++) {
  83. ad_thread.remove();
  84. }
  85.  
  86. var url_path = window.location.pathname;
  87. var url_array = url_path.split("/");
  88.  
  89. // Rechte Seitenleiste auf den Übersichten ausblenden, Schlagworte unten anzeigen
  90. if(url_array[1] == 'board' || url_array[1] == 'active-topic-list' || url_array[1] == 'own-posts-as-threads' || url_array[1] == 'unread-thread-list' || url_array[1] == 'watched-thread-list' || url_array[1] == 'unanswered-thread-list') {
  91. var main = document.getElementsByClassName('main')[0];
  92. if(main) {
  93. var layoutboundary = main.getElementsByClassName('layoutBoundary')[0];
  94. if(layoutboundary) {
  95. var schlagworte = layoutboundary.getElementsByClassName('sidebar boxesSidebarRight')[0].querySelector('section[data-box-identifier="com.woltlab.wbb.BoardTagCloud"]');
  96. layoutboundary.getElementsByClassName('sidebar boxesSidebarRight')[0].remove();
  97. layoutboundary.getElementsByClassName('content content--sidebar-right')[0].setAttribute('class','content');
  98. }
  99. if(schlagworte) {
  100. main.insertAdjacentHTML('afterend', '<div style="border: 1px solid var(--wcfContentContainerBorder);background-color: var(--wcfContentContainerBackground);border-radius: 10px;padding: 20px;margin: 20px;margin-top: 0px;">' + schlagworte.innerHTML + '</div>');
  101. }
  102. }
  103. }
  104.  
  105. }
  106.  
  107. // DOM vollständig aufgebaut?
  108. if (/complete|interactive|loaded/.test(document.readyState)) {
  109. pv_forum();
  110. } else {
  111. document.addEventListener("DOMContentLoaded", pv_forum, false);
  112. }
  113.  
  114. })();

QingJ © 2025

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