Asana subtask auto loadmore

Asana subtask auto load more

ของเมื่อวันที่ 06-04-2020 ดู เวอร์ชันล่าสุด

คุณจะต้องติดตั้งส่วนขยาย เช่น Tampermonkey, Greasemonkey หรือ Violentmonkey เพื่อติดตั้งสคริปต์นี้

คุณจะต้องติดตั้งส่วนขยาย เช่น Tampermonkey หรือ Violentmonkey เพื่อติดตั้งสคริปต์นี้

คุณจะต้องติดตั้งส่วนขยาย เช่น Tampermonkey หรือ Violentmonkey เพื่อติดตั้งสคริปต์นี้

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

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

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

// ==UserScript==
// @name         Asana subtask auto loadmore
// @namespace    http://tampermonkey.net
// @description  Asana subtask auto load more
// @version      0.3
// @author       zhong666
// @match        https://app.asana.com/*
// @grant        none
// ==/UserScript==

(function () {
  'use strict';

  function debounce(func, wait, immediate) {
    var timeout;
    return function() {
      var context = this, args = arguments;
      clearTimeout(timeout);
      timeout = setTimeout(function() {
        timeout = null;
        if (!immediate) func.apply(context, args);
      }, wait);
      if (immediate && !timeout) func.apply(context, args);
    };
  }

  function dispatchClickLoadMore() {
    const $loadmore = document.querySelector('.SubtaskGrid.SingleTaskPaneSpreadsheet-subtaskGrid a.SubtaskGrid-loadMore')
    if (!$loadmore) {
      return
    }
    $loadmore.click()
  }

  dispatchClickLoadMore = debounce(dispatchClickLoadMore, 50)

  const mobs = new MutationObserver((mutations) => {
    mutations.forEach(() => {
      dispatchClickLoadMore()
    })
  })

  mobs.observe(document.body, {
    subtree: true,
    childList: true,
  })
})();