[grom] phpBB forum helper

phpBB: view user's posts and topics; cleans (tab) titles; removes ads and hidden metadata.

  1. // ==UserScript==
  2. // @name [grom] phpBB forum helper
  3. // @namespace grom
  4. // @description phpBB: view user's posts and topics; cleans (tab) titles; removes ads and hidden metadata.
  5. // @version 1.0.1.150211
  6. //// ProSilver \\\\
  7. // @match *://adblockplus.org/forum/*
  8. // @match *://custombuttons.sourceforge.net/forum/*
  9. // @match *://forums.mozillazine.org/*
  10. // @match *://foldingforum.org/*
  11. // @match *://forums.debian.net/*
  12. // @match *://forums.informaction.com/*
  13. // @match *://forums.lanik.us/*
  14. // @match *://forums.linuxmint.com/*
  15. // @match *://forums.sandboxie.com/*
  16. // @match *://forums.virtualbox.org/*
  17. // @match *://forums.wesnoth.org/*
  18. // @match *://forums.xkcd.com/*
  19. // @match *://forum.enjoysudoku.com/*
  20. // @match *://forum.freegamedev.net/*
  21. // @match *://forum.openoffice.org/*
  22. // @match *://forum.palemoon.org/*
  23. // @match *://forum.videolan.org/*
  24. // @match *://ibdof.com/*
  25. // @match *://newsgroup.xnview.com/*
  26. // @match *://www.sublimetext.com/forum/*
  27. // @match *://*.synthesiagame.com/forum/*
  28. //// SubSilver2 \\\\
  29. // @match *://tmp.garyr.net/forum/*
  30. // @match *://ahkscript.org/boards/*
  31. // @match *://www.dostips.com/forum/*
  32. //// SubSilver1 \\\\
  33. // @match *://*.murga-linux.com/puppy/*
  34. // @match *://www.ppmsite.com/forum/*
  35. // @grant none
  36. // @noframes
  37. // @run-at document-end
  38. // ==/UserScript==
  39.  
  40. // shorthands
  41. //function $i(a) { return document.getElementById(a); }
  42. //function $(a,b) { return (b||document.body).querySelector(a); }
  43. function $$(a,b) { return (b||document.body).querySelectorAll(a); }
  44. function $c(a,b) { return (b||document.body).getElementsByClassName(a); }
  45. function $t(a,b) { return (b||document.body).getElementsByTagName(a); }
  46. //function $n(a,b) { return (b||document.body).getElementsByName(a); }
  47. //var $body = document.body;
  48.  
  49. // trim title
  50. var loc = location.hostname;
  51. if (loc.match('adblockplus|custombuttons|foldingforum|debian|informaction|lanik\.us|linuxmint|sandboxie|virtualbox|wesnoth|xkcd\.com|palemoon|ibdof\.com|xnview\.com|sublimetext|synthesiagame'))
  52. document.title=document.title.replace(/^[a-zA-Z\s\.-]+• (?:View topic - |View forum - )?/, '');
  53. else if (loc.match('freegamedev')) document.title=document.title.replace(/(?:Topic - |Forum - )?(.*) • FreeGameDev Forums - Open Source Game Development/, '$1');
  54. else if (loc.match('mozillazine')) document.title=document.title.replace(' • mozillaZine Forums', '');
  55. else if (loc.match('videolan')) document.title=document.title.replace(' - The VideoLAN Forums', '');
  56. else if (loc.match('ahkscript')) document.title=document.title.replace(/ (- View topic )?• AHKScript/, '');
  57. else if (loc.match('dostips')) document.title=document.title.replace(/DosTips.com - (?:View (?:topic|forum) - )?/, '');
  58. else if (loc.match('murga-linux|ppmsite')) document.title=document.title.replace(/^[a-zA-Z\s\.-]+:: (?:View (?:[Ff]orum|[Tt]opic) - )?/, '');
  59.  
  60. // if on Custom Buttons forum
  61. if (loc.match('custombuttons.sourceforge.net')) {
  62. // attach favicon
  63. var link = document.createElement('link');
  64. link.rel = 'icon';
  65. link.type = 'image/png';
  66. link.href = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQAgMAAABinRfyAAAACVBMVEUAU58Ald3/lQA+PJimAAAAI0lEQVQIW2MIBQIGBwYGRiChtRAHAZYFEl4rgEqwEWBZkFEAf58RlaqHEPcAAAAASUVORK5CYII=';
  67. $t('head', document)[0].appendChild(link);
  68. }
  69.  
  70. // remove ads and some metadata
  71. var trash = $$('#gootop, #goobot, .adsbygoogle, meta[name="description"], meta[name="keywords"], meta[name="copyright"], meta[content="IE=EmulateIE7; IE=EmulateIE9"]', document);
  72. for (var i=0,len=trash.length; i<len; i++) trash[i].remove();
  73.  
  74. // view user's posts; DO NOT 'use strict';
  75. // ProSilver
  76. var list = $c('postprofile'),
  77. user;
  78. if (list) {
  79. function mkLink(word, user) { // < breaking 'use strict';
  80. var a = document.createElement('a');
  81. a.title = 'View ' + word + 's';
  82. a.textContent = word;
  83. a.href = 'search.php?sr=' + word + 's&author_id=' + user;
  84. a.className = 'icon-search';
  85. a.style.marginLeft = '.5em';
  86. a.style.opacity = '.7';
  87. // some sites have broken ".icon-search" style; redeclare:
  88. a.style.paddingLeft = '17px';
  89. a.style.backgroundPosition = '0 50%';
  90. a.style.backgroundRepeat = 'no-repeat';
  91. return a;
  92. }
  93. for (var i=0,len=list.length; i<len; i++) {
  94. user = $t('a', list[i])[0];
  95. if (!user) { continue; } // where registration not required
  96. user = user.href.match(/\d+/)[0];
  97. list[i].appendChild(mkLink('post', user));
  98. list[i].appendChild(mkLink('topic', user));
  99. }
  100. }
  101. // SubSilver2
  102. var list = $c('postauthor');
  103. if (list) {
  104. function mkLink(word, user) { // < breaking 'use strict';
  105. var a = document.createElement('a');
  106. a.title = 'View ' + word;
  107. a.textContent = word;
  108. a.href = 'search.php?sr=' + word + '&author=' + user;
  109. a.style.margin = '0 .5em';
  110. a.style.opacity = '.5';
  111. return a;
  112. }
  113. for (var i=0,len=list.length; i<len; i++) {
  114. user = list[i].textContent;
  115. list[i].appendChild(document.createElement('br'));
  116. list[i].appendChild(mkLink('posts', user));
  117. list[i].appendChild(mkLink('topics', user));
  118. }
  119. }
  120. // SubSilver1
  121. var list = $c('name');
  122. if (list) for (var i=0,len=list.length; i<len; i++) {
  123. user = list[i].textContent;
  124. var a = document.createElement('a');
  125. a.title = 'View posts';
  126. a.href = 'search.php?search_author=' + user;
  127. a.style.marginLeft = '.5em';
  128. var img = a.appendChild(document.createElement('img'));
  129. img.src = 'templates/subSilver/images/icon_mini_search.gif';
  130. img.style.verticalAlign = 'bottom';
  131. list[i].appendChild(a);
  132. }
  133.  
  134. // clear memory
  135. var loc='', trash='', a='', list='', user='', i='', len='';

QingJ © 2025

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