Easy Analysis Extension

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

目前為 2015-12-11 提交的版本,檢視 最新版本

// ==UserScript==
// @name         Easy Analysis Extension
// @version      1.4
// @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     12/11/2015
// @author       Myfreedom614 <[email protected]>
// @supportURL   http://openszone.com/
// @match        https://social.msdn.microsoft.com/Forums/*
// @match        https://social.technet.microsoft.com/Forums/*
// @exclude      https://social.msdn.microsoft.com/Forums/*/home*
// @exclude      https://social.technet.microsoft.com/Forums/*/home*
// @grant        none
// @copyright	 2015, 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})";

        var re = new RegExp(regSite);

        if (siteurl.match(re)) {

            var myArray = re.exec(siteurl);

            var sidebar = document.getElementById('sidebar');

            var firstChild = sidebar.getElementsByTagName('section')[0];

            var section = document.createElement('section');

            var url = '//analyzeit.azurewebsites.net/Redirection/Navigate/' + myArray[1] + '?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[1] +"?external=mt' style='cursor: pointer;margin-left: -10px;'><img src='http://findicons.com/icon/download/263492/tag_purple/32/png' class='icon' style='width: 25px;height: 25px;'></a>";
            }
        }
    }
    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;
})();