Easy Analysis Extension

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

当前为 2016-01-27 提交的版本,查看 最新版本

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

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

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         Easy Analysis Extension
// @version      1.7
// @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     1/27/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://greasyfork.org/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');
    }

    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 = '<div id="eas-iframe" style="height:500px;"><iframe src="' + url + '" style="width:100%;height:100%;"></iframe></div>';

                sidebar.insertBefore(section, firstChild);

                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>';
                sidebar.insertBefore(adddiv, firstChild);
            }

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

    window.addin = this;
})();