Easy Analysis Extension

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

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

// ==UserScript==
// @name         Easy Analysis Extension
// @version      1.0
// @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/08/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,Myfreedom614
// @namespace https://greasyfork.org/users/4544
// ==/UserScript==

(function() {
    'use strict';
    function UserException(message) {
        this.message = message;
        this.name = "UserException";
    }

    try {
        var siteurl = document.URL;
        var re = new RegExp("({{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})");
        if (siteurl.match(re)) {
            //alert("Successful match");
            var myArray = re.exec(siteurl);
            var isAdded = document.getElementById('earedirect');
            if(isAdded === null)
            {
                var div = document.getElementById('threadPageContainer').getElementsByTagName('h1')[0];
                div.innerHTML += "<a id='earedirect' target='_blank' href='http://analyzeit.azurewebsites.net/Redirection/Navigate/"+ myArray[0] +"?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>";
            }
        } else {
            //alert("No match");
            throw new UserException("Can't extract the case id");
        }
    }
    catch(err) {
        //alert(err.message);
        if (confirm(err.message + ', report it now ?')) {
            window.location = "https://github.com/dream-365/easy-analysis/issues";
        } else {
            // Do nothing!
        }
    }
})();