YouTube to YTPak

Changes all the YouTube links on a page to YTPak links

2014-08-07 يوللانغان نەشرى. ئەڭ يېڭى نەشرىنى كۆرۈش.

// ==UserScript==
// @name        YouTube to YTPak
// @namespace   Sarmad Khan
// @description Changes all the YouTube links on a page to YTPak links
// @include     http://*
// @include     https://*
// @require     http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js
// @version     0.2
// ==/UserScript==

this.$ = this.jQuery = jQuery.noConflict(true);

function replace(e) {
    $('a').each(function(){
        this.href = this.href.replace('youtube.com/watch?v=', 'ytpak.com/?component=video&task=view&id=');
    }); 
    $('iframe').each(function(){
            $(this).attr('src',src.replace('youtube.com/embed/', 'playit.pk/embed?v='));
            var src = $(this).attr('src');
            var index = src.indexOf('?');
                src = src.substring(0,index);
        }); }

$(function () { replace(); });
$(document).bind('keypress', function (e) { if (e.keyCode == 96) { replace(e); } });