Kami PDF Smart Auto Save & Quick Open

Auto-save kami pdf and quickly open the document with the most annotations

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name         Kami PDF Smart Auto Save & Quick Open
// @namespace    http://tampermonkey.net/
// @version      0.9
// @description  Auto-save kami pdf and quickly open the document with the most annotations
// @author       John Ren
// @match        https://web.kamihq.com/web/viewer*
// @run-at       document-idle
// @grant        none
// ==/UserScript==

(function() {
  let check=setInterval(() => {
    var comments_btn = $(".comments");
    if (comments_btn[0]) {
    if (!comments_btn.hasClass("chosen")) {
      comments_btn.click();
    }
    setTimeout(() => {
      if ($(comments_btn.children()[0]).hasClass("fa-arrow-up")) {
        comments_btn.click();
      }
      setTimeout(() => {
        $('[ng-repeat="document in documents"]')[0].click();
        setTimeout(() => {
          $('[ng-click="open_document(selected)"]').click();
        }, 30);
      }, 30);
    }, 30);
    clearInterval(check);
    }
  }, 100);
  setTimeout(()=>{clearInterval(check);},10000);
})();

(function() {
  setInterval(() => {
    var sync_needed = $(".fa.fa-bolt").length !== 0;
    if (sync_needed) {
      var save_btn = $("[ng-click=\"sync_now('drive')\"]");
      save_btn.click();
    }
  }, 5000);
})();