انتقل إلى المحتوى

مستخدم:ASammour/light.js

من ويكيبيديا، الموسوعة الحرة

ملاحظة: بعد الحفظ، قد يلزمك إفراغ الكاش لرؤية التغييرات.

importStylesheet( 'User:ASammour/test.css' );

var myArray = [];

function getContent (title){
    var mycontent;
    for (var i=0;i<myArray.length;i++){
        if (myArray[i].split("*******")[0] == title){
            mycontent = myArray[i].split("*******")[1];
        }
    }
    return mycontent;
}

$(document).on('mouseenter', 'a', function(e) {
    //e.preventDefault();
    var title = "https://ar.wikipedia.org"+$(this).attr('href');
    if (!title.includes("rollback")){
        $.get(title, function( data ) {
            myArray.push(title+"*******"+data);
        });
    }
});

$(document).on('click', 'a', function(e) {
    e.preventDefault();
    var mytitle = "https://ar.wikipedia.org"+$(this).attr('href');
    var content = getContent (mytitle);
    if (content === undefined){
        $.get(mytitle, function( data ) {
            $("body").html('');
            $("body").html(data);
        });
    }
    $("body").html('<div class="loader">Loading...</div>');
    $("body").html(content);
    window.scrollTo(0, 0);
    window.history.pushState('page2', 'Title', mytitle);
});