Asana Updates

Updates elements of Asana to make it better. Configurable (turn options on/off) within the code.

当前为 2020-09-11 提交的版本,查看 最新版本

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         Asana Updates
// @namespace    http://
// @description  Updates elements of Asana to make it better. Configurable (turn options on/off) within the code.
// @author       Wes Foster | WesFoster.com
// @match        https://app.asana.com/*
// @grant        GM_addStyle
// @version      2.1.4
// @history      2.1.4: Made the features all optional. And added script description
// @history      2.1.3: Fixed syntax error
// @history      2.1.2: Enforced hidden harvest icon
// ==/UserScript==

(function() {
    'use strict';

    var options = {
			"resizeSidebar"   : true,
			"removeHarvest"   : true,
			"autoShowProjects": true,
			"customBackground": false, 	// Set an image URL if you want this turned on.
			"hidePremiumNags" : false, 	// If true, this will remove some of the upgrade nags (buttons, banners, etc.)
			"hidePortfolios"  : false 	// If true, this will remove the portfolios link
    };


    // Remove Premium Elements
    if ( options.hidePremiumNags ) {
	    GM_addStyle("#topbar, .TopbarPageHeaderGlobalActions-upgradeButton, .TaskPremiumFeaturesSection { display: none !important; }");
    }
    if ( options.hidePremiumNags ) {
	    GM_addStyle(".SidebarTopNavLinks-myPortfoliosbutton { display: none !important; }");
	  }

    // Custom Background image
    if ( options.customBackground !== false ) {
	    GM_addStyle(".themeBackground-valley {background-image:url('" + options.customBackground + "') !important}");
	  }    

    // Resize the left sidebar
    if ( options.resizeSidebar ) {
	    var asanaSidebarWidth = 350;
	    GM_addStyle(".AsanaMain-sidebar {width: " + asanaSidebarWidth + "px !important;}");
	    GM_addStyle(".AsanaMain-sidebar.AsanaMain-sidebar--isCollapsed {margin-left: " + asanaSidebarWidth*-1 + "px !important;}");
    }

    // Remove harvest time-tracker icon
    if ( options.resizeSidebar ) {
	    GM_addStyle(".HarvestButton-timerIcon, .HarvestButton, .harvest-timer {display: none !important;}");
	  }

    // Recurring Interval to show projects in Asana
    if ( options.autoShowProjects ) {
	    var timerID = setInterval(performIntervalActions, 1000);
	    function performIntervalActions() {
	        var i;

	        // Expand "Show More Projects"
	        var projectLink = document.getElementsByClassName("SidebarTeamDetailsProjectsList-showMoreProjectsLink");
	        for (i = 0; i < projectLink.length; i++) {
	            projectLink[i].click();
	        }

	        // Expand Project Description
	        var projectDescBox = document.getElementsByClassName('ql-editor');
	        var sidebarHeightRestriction = 137; // Roughly the height of the header toolbar and margins
	        for (i = 0; i < projectDescBox.length; i++) {
	            projectDescBox[i].style.maxHeight = (document.getElementsByClassName('ProjectPageView')[0].clientHeight - sidebarHeightRestriction) + "px";
	        }
	    }
	    setTimeout(function(){ clearInterval(timerID);} , 30000);
	  }

})();