Made a Greasemonkey script to allow expanding codeboxes of forum's prosilver theme. INSTALLATION:
- First install Greasemonkey for Firefox ; or it's browser-specific clones: Tampermonkey for Opera / Chrome
- Then copy the code below
- Installation instructions for Firefox/Greasemonkey:
- Then open Firefox's Addon Manager -> User Scripts tab -> click the "New User Script" button.
- And then click the "Use Script from Clipboard" button.
- Installation instructions for Chrome+Opera/Tampermonkey:
- Click the Tampermonkey toolbar button, click "Dashboard".
- Then again click the Tampermonkey toolbar button, this time click "Add a new script...".
- Paste the copied code into the textbox and save (CTRL+S).
Code: Select all
// ==UserScript==
// @name XYBetaClub ProSilver CodeBox Expander
// @namespace "SammaySarkar_GMScripts"
// @description expand/collapse phpbb ProSilver theme's codeboxes. Intended for XYplorer Beta Club
// @version 3.1
// @author SammaySarkar
// @include /^https?\://(www.)?xyplorer\.com/xyfc/viewtopic\.php\?.*/
// @include /^https?\://(www.)?xyplorer\.com/xyfc/posting\.php\?.*/
// @grant none
// ==/UserScript==
(function (){
var expandAll = 1;
var codeBoxArray = document.querySelectorAll('dl.codebox code');
if (codeBoxArray.length > 0) {
var selBtnArray = document.querySelectorAll('dl.codebox dt');
for (var i = 0; i < codeBoxArray.length; i++) {
selBtnArray[i].innerHTML = selBtnArray[i].innerHTML +
' // <a href="#" onclick="return false;" class="expand_btn">Expand</a>';
if (expandAll == 1) {
selBtnArray[i].parentNode.getElementsByTagName('code')[0].style.maxHeight = 'none';
selBtnArray[i].parentNode.getElementsByTagName('code')[0].style.overflowY = 'auto';
selBtnArray[i].parentNode.getElementsByTagName('code')[0].style.whiteSpace = 'pre';
}
document.getElementsByClassName("expand_btn")[i].addEventListener('click', function () {
var coCode = this.parentNode.parentNode.getElementsByTagName('code')[0];
var coCodeH = window.getComputedStyle(coCode,null).getPropertyValue('max-height');
if (coCodeH != 'none'){
coCode.style.maxHeight = 'none';
coCode.style.overflowY = 'auto';
coCode.style.whiteSpace = 'pre';
} else if (coCodeH == 'none'){
coCode.style.maxHeight = '200px';
coCode.style.overflowY = 'auto';
coCode.style.whiteSpace = 'normal';
}
});
}
}
})();
// == changelog ==
// v3.1 expanding also toggles off auto-wrapping in codeboxes
// v3 sanity check.
// also variable expandAll controls initial toggled state of codeboxes.
// includes posting.php (create+edit post)
// v2.1 tweaked @include regExp to re-support Firefox
// v2 converted @include to regExp, to make scipt compatible with Opera/Tampermonkey
// v1 hello internet!Installation steps in other browsers may vary. Also may not work in other browsers.
XYplorer Beta Club