Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Lysak/5f684b9d6aa417cfbfa530ef96bd0d15 to your computer and use it in GitHub Desktop.
Save Lysak/5f684b9d6aa417cfbfa530ef96bd0d15 to your computer and use it in GitHub Desktop.
Automatically enable filter "Just my tasks" in Asana project
// ==UserScript==
// @name Automatically enable filter "Just my tasks" in Asana project
// @namespace https://github.com/Lysak
// @version 0.1.5
// @description Automatically enable filter "Just my tasks" in Asana project (Code License: MIT License)
// @author Dmytrii Lysak @Lysak
// @match https://app.asana.com/*
// @icon https://www.google.com/s2/favicons?domain=asana.com
// @grant none
// @noframes
// ==/UserScript==
// Revision history
// 0.1 Initial implementation
// 0.1.2
// 0.1.3 03.08.2022 - Final version
// 0.1.4 27.10.2022 - fixed filter menu selector name after Asana update
// 0.1.5 29.11.2022 - update again: fixed filter menu selector name after Asana update
const filterMenuClassName = '.PageToolbarStructure-rightChildren .SubtleToggleButton';
document.querySelectorAll(filterMenuClassName)
function asana() {
setTimeout(function() {
if (document.querySelectorAll(filterMenuClassName)[0]?.textContent === 'Filter') {
console.log("Automatically enable filter \"Just my tasks\" in Asana project: load init");
document.querySelectorAll(filterMenuClassName)[0].click();
document.querySelector(".MenuPresentation .MenuItemA11y").click()
console.log("Automatically enable filter \"Just my tasks\" in Asana project: load complete");
}
}, 1000);
}
// Convenience function to execute your callback only after an element matching readySelector has been added to the page.
// Example: runWhenReady('.search-result', augmentSearchResults);
// Gives up after 1 minute.
// https://github.com/Tampermonkey/tampermonkey/issues/1279#issuecomment-875386821
function runWhenReady(readySelector, callback) {
var numAttempts = 0;
var tryNow = function() {
var elem = document.querySelector(readySelector);
if (elem) {
callback(elem);
} else {
numAttempts++;
if (numAttempts >= 34) {
console.warn('Giving up after 34 attempts. Could not find: ' + readySelector);
} else {
setTimeout(tryNow, 250 * Math.pow(1.1, numAttempts));
}
}
};
tryNow();
}
runWhenReady(filterMenuClassName, asana);
@zxcv551133
Copy link

zxcv551133 commented Aug 19, 2022

Hi are there any comment to run this script?
Is it compatible for windows os?
I use tempermonkey with chrome v104.0.5112.101
but this doen't seem to be executed except when page refreshed

I tried simple alert("helloworld") but this doesn't work either

Is there any additional config to solve it?

@Lysak
Copy link
Author

Lysak commented Aug 20, 2022

Hi are there any comment to run this script? Is it compatible for windows os? I use tempermonkey with chrome v104.0.5112.101 but this doen't seem to be executed except when page refreshed

I tried simple alert("helloworld") but this doesn't work either

Is there any additional config to solve it?

I just test it, working correctly

Requirements:

  • browser with Tampermonkey extension
  • English language in asana
  • need to click Raw button on gist script page
  • in a new tab will be open Tampermonkey installation script page

after installation need to refresh asana page with cache Cmd+Shift+R (Ctrl+Shift+R)

@mikeestablish
Copy link

Hey Lysak, love the tamper monkey workaround you found for the custom view in Asana since they currently don’t have that feature. Great work!

Would it be possible to create this for a custom field instead of the my tasks filter? I'm looking to do this exact thing but for a custom people field for my team.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment