quick_links

quick articles preview for sportdog.gr

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name        quick_links
// @namespace   gt
// @description quick articles preview for sportdog.gr
// @include     http://www.sportdog.gr/*
// @version     1.0
// @grant       none
// @require http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js
// @require https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.6/js/bootstrap.min.js
// ==/UserScript==

jQuery(window).load(function(){

    jQuery('head').append('<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.6/css/bootstrap.min.css" type="text/css" />');
    jQuery('head').append('<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.5.0/css/font-awesome.min.css" type="text/css" />');

    createModalBox();
    var title = jQuery(".view-content .views-field-title")
    jQuery.each(title, function(){
        var element = jQuery(this);
        var url = element.find("a").attr("href");

        var modalButtonHTML = '' +
            '<button type="button" class="btn btn-info btn-lg" data-toggle="modal" data-target="#myModal"><span class="fa fa-search"></span></button>';

        element.html(modalButtonHTML+element.html());


        element.find("button").attr("style", 'width: 20px; float: left;height: 20px;font-size: 12px;margin-left: -2px;padding: 0px;margin-right: 4px;')
        element.find("button").click(function(){
            preview(url);
        })

    })

    function preview(url){
        var finalURL = url + " .node-content";
        var modalContent = jQuery('.modal-body');
        modalContent.html("<span class='fa fa-spinner fa-spin'></span>");
        modalContent.load(finalURL)
    }

    function createModalBox(html){

        var boxHTML = '' +
            '<div class="modal fade" id="myModal" role="dialog">' +
            '   <div class="modal-dialog">' +
            '   <!-- Modal content-->' +
            '       <div class="modal-content">' +
                '       <div class="modal-header">' +
                '           <button type="button" class="close"data-dismiss="modal">&times;</button>' +
                '           <h4 class="modal-title"></h4>' +
                '       </div>' +
                    '   <div class="modal-body">' +
                    '   </div>' +
                    '   <div class="modal-footer">' +
                    '       <button type="button" class="btnbtn-default"data-dismiss="modal">Κλείσιμο</button>' +
                    '   </div>' +
                   '</div>' +
               '</div>' +
            '</div>';
        var div = jQuery("<div>");
        div.html(boxHTML);
        div.appendTo(jQuery('body'));
    }

})