Pferd.de quote split

Quote split button for pferd.de

Bu betiği kurabilmeniz için Tampermonkey, Greasemonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği yüklemek için Tampermonkey gibi bir uzantı yüklemeniz gerekir.

Bu betiği kurabilmeniz için Tampermonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği kurabilmeniz için Tampermonkey ya da Userscripts gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği indirebilmeniz için ayrıca Tampermonkey gibi bir eklenti kurmanız gerekmektedir.

Bu komut dosyasını yüklemek için bir kullanıcı komut dosyası yöneticisi uzantısı yüklemeniz gerekecek.

(Zaten bir kullanıcı komut dosyası yöneticim var, kurmama izin verin!)

Bu stili yüklemek için Stylus gibi bir uzantı yüklemeniz gerekir.

Bu stili yüklemek için Stylus gibi bir uzantı kurmanız gerekir.

Bu stili yükleyebilmek için Stylus gibi bir uzantı yüklemeniz gerekir.

Bu stili yüklemek için bir kullanıcı stili yöneticisi uzantısı yüklemeniz gerekir.

Bu stili yüklemek için bir kullanıcı stili yöneticisi uzantısı kurmanız gerekir.

Bu stili yükleyebilmek için bir kullanıcı stili yöneticisi uzantısı yüklemeniz gerekir.

(Zateb bir user-style yöneticim var, yükleyeyim!)

// ==UserScript==
// @name        Pferd.de quote split
// @author	[email protected]
// @namespace   withers
// @description Quote split button for pferd.de
// @include     http://www.pferd.de/threads/*
// @include     http://www.pferd.de/newreply.php*
// @include	http://www.pferd.de/private.php?do=showpm*
// @include	http://www.pferd.de/private.php?do=newpm*
// @include	http://www.pferd.de/private.php?do=insertpm*
// @version     1
// @grant       none
// ==/UserScript==

var repeats = 0;

window.addEventListener("load", function load(event) {
	window.removeEventListener("load", load, false);
	window.setTimeout(addButton, 100);
}, false);

function insertSplit()
{
	var txt;

	txt = document.getElementsByClassName('cke_source cke_enable_context_menu');
	if (txt.length > 0) {
		var sel = txt[0].selectionStart;
		txt[0].value = txt[0].value.substring(0, sel) + '[/QUOTE][QUOTE]' +
			txt[0].value.substring(sel);
	}
}

function addButton() 
{
	var quoteBtns;

	quoteBtns = document.getElementsByClassName('cke_off cke_button_Quote');
	if (quoteBtns.length > 0) {
		var splitBtnWrapper;
		var splitBtn;
		var splitBtnIcon;
		var qbParent;
		var splitImg;

		splitImg = document.createElement('img');
		splitImg.width = 16;
		splitImg.height = 16;
		/* overlay image to make the quote icon look split up */
		splitImg.src = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABmJLR0QAMwAzADOGP0P2AAAACXBI' +
			'WXMAAAsTAAALEwEAmpwYAAAAB3RJTUUH3goSBw8aK/WjegAAAB1pVFh0Q29tbWVudAAAAAAAQ3Jl' +
			'YXRlZCB3aXRoIEdJTVBkLmUHAAAAZ0lEQVQ4y2NgGAW0AcbGxv8JicH4jPgUnT17lhEmdubMGQYT' +
			'E5NHDAwMcjA+IyMjI1yjsbHxf3SATQwZwG0iRiO6GMxlLMhONjExQWFDnf0R6h0BExMTZC+yo/id' +
			'mIBDk+MdTW5UAgCEN4C2CPr5kwAAAABJRU5ErkJggg==';

		splitBtnWrapper = document.createElement('span');
		splitBtnWrapper.className = 'cke_button';

		splitBtn = document.createElement('a');
		splitBtn.className = 'cke_off cke_button_Quote';
		splitBtn.addEventListener('click', insertSplit, true);
		splitBtn.setAttribute('role', 'button');
		splitBtn.setAttribute('title', 'Zitat splitten');

		splitBtnWrapper.appendChild(splitBtn);
		splitBtnIcon = document.createElement('span');
		splitBtnIcon.className = 'cke_icon';
		splitBtnIcon.appendChild(splitImg);
		splitBtn.appendChild(splitBtnIcon);

		qbParent = quoteBtns[0].parentNode.parentNode;
		qbParent.appendChild(splitBtnWrapper);
	} else {
		/* 
		 * Dirty hack to make sure this executes AFTER the editor has
		 * finished loading.
		 */
		if (repeats++ < 60)
			window.setTimeout(addButton, 1000);
	}
}