StumbleOut

Breaks the original link out of StumbleUpon frames and rewrites YouTube embed URLs to their proper video pages.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey, το Greasemonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Userscripts για να εγκαταστήσετε αυτόν τον κώδικα.

You will need to install an extension such as Tampermonkey to install this script.

Θα χρειαστεί να εγκαταστήσετε μια επέκταση διαχείρισης κώδικα χρήστη για να εγκαταστήσετε αυτόν τον κώδικα.

(Έχω ήδη έναν διαχειριστή κώδικα χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(Έχω ήδη έναν διαχειριστή στυλ χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

// ==UserScript==
// @name        StumbleOut
// @version     2.3
// @author      raina
// @namespace   raina
// @description Breaks the original link out of StumbleUpon frames and rewrites YouTube embed URLs to their proper video pages.
// @license     http://www.gnu.org/licenses/gpl-3.0.txt
// @include     http://www.stumbleupon.com/su/*
// @run-at      document-start
// @grant       none
// ==/UserScript==
(function() {
	"use strict";


	var ready = function() {
		if ("complete" === document.readyState) {
			observe();
		}
	};


	var observe = function() {
		var observer = new MutationObserver(function(mutations) {
			mutations.forEach(function(mutation) {
				if ("class" === mutation.attributeName) {
					if ("undefined" === typeof iframe || !iframe) {
						iframe = document.querySelector('.stumble-frame');
					}
					if ("undefined" !== typeof iframe && iframe) {
						if (/youtube\.com\/embed/.test(iframe.src)) {
							var video = iframe.src.replace(/(embed\/)([\w\d-]+)(\?.*$)/, "watch?v=$2");
							var timestamp;
							if (timestamp = iframe.src.match(/t=\d+m\d+s/)) {
								video += "&" + timestamp[0];
							}
							window.location.href = video;
						} else {
							window.location.href = iframe.src;
						}
						observer.disconnect();
					}
				}
			});
		});
		var config = {attributes: true};
		observer.observe(document.body, config);
	}


	if (window.self === window.top) {
		var iframe;
		document.addEventListener("readystatechange", ready, false);
	}
}());