SG Youtube Button

Sepak

Cocaine
Staff member
Moderator
I have made an extension for google chrome that will allow you to paste a youtube link and will parse it to being able to embed it in the forums.
A firefox version might be in the way as well.

Installation Guide:
1. Download the extension from here: https://hostr.co/des5KDekdpIg
2. Open Google Chrome Extension Page
3. Drag the "SGYoutubeButton.crx" and drop it inside the extensions page.
4. Accept the installation and done.

Donate to my Paypal account to keep making projects for you: [email protected]

Next Project:
-Resizable images.





 

Sepak

Cocaine
Staff member
Moderator
Sure, it's javascript:
Code:
function findTableDescendant(tagname)
{
	var parent = document.getElementById("vB_Editor_QR_controls");
	if(parent == null){
		parent = document.getElementById("vB_Editor_001_controls");
		var descendants = parent.getElementsByTagName(tagname);
		if ( descendants.length)
			return descendants[6];
		else
			return null;
	}else{
		var descendants = parent.getElementsByTagName(tagname);
		if ( descendants.length)
			return descendants[0];
		else
			return null;
	}
}
if( document.getElementById("vB_Editor_QR_controls") || document.getElementById("vB_Editor_001_controls")){
	var button = document.createElement("div");
	button.style.color = "#000000";
	button.style.padding = 1;
	button.style.border = "none";
	button.style.background = "#e1e1e2";
	button.onmouseover = function(){
		button.style.background = "#c1d2ee";
		button.style.border = "1px solid #316AC5";
	}
	button.onmouseout = function(){
		button.style.background = "#e1e1e2";
		button.style.border = "none";
	}
	var image = document.createElement("img");
	image.type = 'image';
	image.src = chrome.extension.getURL("images/ybi.png");
	image.width = 21;
	image.height = 20;
	image.alt = "Insert Youtube Link";
	image.title = "Insert Youtube Link";
	button.appendChild(image);
	button.onclick = function(){
		button.style.background = "#98b5e2";
		button.style.border = "1px solid #316AC5";
		var link = prompt("Please enter the URL of your Youtube Video:","http://");
		if(link != null){
			var rlink;		
			if(link.indexOf("youtu.be")!= -1){
				if(link.indexOf("?")!= -1){
					rlink = link.substring(link.indexOf("e/")+2, link.indexOf("?"));
				}else{
					rlink = link.substring(link.indexOf("e/")+2, link.length);
				}
			}else if(link.indexOf("watch?v")!= -1){
				if(link.indexOf("&")!= -1){
					rlink = link.substring(link.indexOf("?v")+3, link.indexOf("&"));
				}else{
					rlink = link.substring(link.indexOf("?v")+3, link.length);
				}
			}else{
				rlink = link;
			}
			var txtarea = document.getElementById("vB_Editor_QR_textarea");	
			if(txtarea == null){
				txtarea = document.getElementById("vB_Editor_001_textarea");
			}
			var startPos;
			var endPos;
			if (txtarea.selectionStart || txtarea.selectionStart == '0') {
				startPos = txtarea.selectionStart;
				endPos = txtarea.selectionEnd;
				txtarea.value = txtarea.value.substring(0, startPos)
					+ "[youtbe]"
					+ rlink
					+ "[/youtbe]"
					+ txtarea.value.substring(endPos, txtarea.value.length);
			} else {
				txtarea.value = txtarea.value
					+ "[youtbe]"
					+ rlink
					+ "[/youtbe]";
			}
			txtarea.focus();
			txtarea.selectionStart = startPos + 9;
			txtarea.selectionEnd = startPos + 9 + rlink.length;
		}
	}
	
	var table = findTableDescendant("table");
	var p = document.getElementById("vB_Editor_QR_controls");
	if(p == null){
		var newRow = table.rows[0];
		var newCell  = newRow.insertCell(17);
		newCell.appendChild(button);
	}else{
		var newRow = table.rows[0];
		var newCell = newRow.insertCell(10);
		newCell.appendChild(button);	
	}
}
 

Sepak

Cocaine
Staff member
Moderator
It seems chrome blocks the extension because it's not in the store, the fuckers. If you donate me 5 dollars (that's what it costs to publish it), I'll do it.

But there's a workaround. Uncompress the .crx file, and in the extensions page, enable developers mode. Click 'load uncompressed extension', find the uncompressed folder containing the extension and select it. Now you have it.
 

Sepak

Cocaine
Staff member
Moderator
Thanks for the appreciation, Not like the rest of the fuckers in this forum.
 

Sepak

Cocaine
Staff member
Moderator
A guy gave 24 euros. And I thought it would make the life easier for Jaboldinho in his music thread :(
 

krisaju95

Manager
Administrator
Moderator
Super Moderator
nady;3867992 said:
Who are you? How come you are a moderator?

well, they were accepting applications for new moderators, i applied, i got accepted, and here i am :)
 


Top