Easy Analysis Extension

Easy Analysis Extension(http://analyzeit.azurewebsites.net/)

目前为 2016-02-29 提交的版本。查看 最新版本

// ==UserScript==
// @name         Easy Analysis Extension
// @version      1.8
// @description  Easy Analysis Extension(http://analyzeit.azurewebsites.net/)
// @icon         https://www.microsoft.com/favicon.ico?v2
// @license      GPL version 3
// @encoding     utf-8
// @date         12/08/2015
// @modified     2/29/2016
// @author       Myfreedom614 <[email protected]>
// @supportURL   http://openszone.com/
// @match        https://social.msdn.microsoft.com/Forums/*
// @match        https://social.technet.microsoft.com/Forums/*
// @match        http://stackoverflow.com/questions/*
// @match        https://stackoverflow.com/questions/*
// @exclude      https://social.msdn.microsoft.com/Forums/*/home*
// @exclude      https://social.technet.microsoft.com/Forums/*/home*
// @grant        none
// @copyright	 2015-2016, Jeffrey Chen, Franklin Chen
// @namespace https://gf.qytechs.cn/users/4544
// ==/UserScript==

(function () {
    'use strict';
    if (typeof window.addin !== 'undefined') {
        return;
    }
    function UserException(message) {
        this.message = message;
        this.name = "UserException";
    }
    function OpenLinkNewTab(link) {
        window.open(link, '_blank');
    }
    function InsertMSDNIframe(link) {
        var goToSection = document.getElementById('eas-iframe');
        var section = document.createElement('section');
        section.innerHTML = '<div id="eas-iframe" style="height:500px;"><iframe src="' + link + '" style="width:100%;height:100%;"></iframe></div>';
        goToSection.parentNode.replaceChild(section, goToSection);
    }
    function InsertSOIframe(link) {
        var goToSection = document.getElementById('eas-iframe');
        var divs = document.createElement('div');
        divs.innerHTML = '<div class="module" id="eas-iframe" style="height:500px;"><iframe src="' + link + '" style="width:100%;height:100%;"></iframe></div>';
        var div= divs.firstChild;
        goToSection.parentNode.replaceChild(div, goToSection);
    }

    try {
        var isAdded = document.getElementById('eas-iframe');

        if (isAdded !== null) {
            return;
        }

        var siteurl = document.URL;

        var regSite = "(social..*.microsoft.com/Forums/.*/({{0,1}([0-9a-fA-F]){8}-([0-9a-fA-F]){4}-([0-9a-fA-F]){4}-([0-9a-fA-F]){4}-([0-9a-fA-F]){12}}{0,1}))|(stackoverflow.com/questions/([0-9]*)/)";

        var re = new RegExp(regSite);

        if (siteurl.match(re)) {
            var myArray = re.exec(siteurl);
            var sidebar = document.getElementById('sidebar');
            if(sidebar === null )
                return;
            var firstChild = sidebar.getElementsByTagName('section')[0];
            if(firstChild!==undefined){
                //MSDN
                var section = document.createElement('section');
                var url = '//analyzeit.azurewebsites.net/Redirection/Navigate/' + myArray[2] + '?external=mt&type=iframe';
                section.innerHTML = '<section id="eas-iframe"><div><a id="gotoeas" class="btn goToEALink" title="Load EA iframe" href="#" style="color: #fff;background-color: #1e75bb;line-height: normal;padding: .3em 1em .48em 1em;display: block;">Easy Analysis</a></div></section>';
                sidebar.insertBefore(section, firstChild);
                document.getElementById("gotoeas").addEventListener("click", function(){
                    InsertMSDNIframe(url);}, false);

                var isAddedLink = document.getElementById('earedirect');
                if(isAddedLink === null)
                {
                    var div = document.getElementById('threadPageContainer').getElementsByTagName('h1')[0];
                    div.innerHTML += "<a id='earedirect' target='_blank' href='http://analyzeit.azurewebsites.net/Redirection/Navigate/"+ myArray[2] +"?external=mt' style='cursor: pointer;margin-left: -10px;'><img src='http://skift.com/wp-content/themes/skift/img/redesign/sprites/tag.png' class='icon' style='width: 25px;height: 25px;'></a>";
                }
            }else {
                //StackOverflow
                regSite = "stackoverflow.com/questions/([0-9]*)/";
                re = new RegExp(regSite);
                myArray = re.exec(siteurl);
                firstChild = sidebar.getElementsByTagName('div')[0];
                var adddiv = document.createElement('div');
                var sourl = '//analyzeit.azurewebsites.net/Redirection/Navigate/' + myArray[1] + '?external=sotool&type=iframe';
                //adddiv.innerHTML = '<div class="module" id="eas-iframe" style="height:500px;"><iframe src="' + sourl + '" style="width:100%;height:100%;"></iframe></div>';
                adddiv.innerHTML = '<div class="module" id="eas-iframe"><a id="gotoeas" href="#" style="color: #FFFFFF;background: #1e75bb;padding: 4px 10px 5px;font-size: 14px;line-height: 1.3;display: block;">Easy Analysis</a></div>';
                sidebar.insertBefore(adddiv, firstChild);
                document.getElementById("gotoeas").addEventListener("click", function(){
                    InsertSOIframe(sourl);}, false);
            }

        }
    }
    catch (err) {
        //alert(err.message);
        if (confirm(err.message + ', report it now ?')) {
            OpenLinkNewTab("https://github.com/myfreedom614/easy-analysis/issues");
        } else {
            // Do nothing!
        }
    }

    window.addin = this;
})();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址