SharePointUsage

Show sharepoint usage at the left bottom on the sharepoint web page.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name        SharePointUsage
// @name:zh-cn     SharePoint剩余空间
// @namespace   benzbrake-sharepoint-usate
// @match       https://*.sharepoint.com/personal/*/_layouts/15/onedrive.aspx*
// @grant       GM_xmlhttpRequest
// @version     1.0
// @author      Ryan
// @run-at      document-end
// @description Show sharepoint usage at the left bottom on the sharepoint web page.
// @description:zh-cn Sharepoint 页面左下角显示剩余空间
// ==/UserScript==
let stormanLink = location.href.split('?')[0].replace('onedrive.aspx', 'storman.aspx'),
    stormanHTML = '',
    cl;

function addLink() {
  let section = document.querySelector('.LeftNav-notifications-section');
  let div = document.createElement('div');
  if (section && stormanHTML.length > 0) {
    clearInterval(cl);
    let div = document.createElement('div');
    div.style.textAlign = 'center';
    div.innerHTML = stormanHTML;
    let progressBar = div.querySelectorAll('.ms-storman-quotabarnormalcol')[0];
    progressBar.style.border = '1px solid #649b61';
    progressBar.style.margin = '5px';
    section.insertBefore(div, section.querySelectorAll('a')[0]);
  }
}

GM_xmlhttpRequest({
    method: "GET",
    url: stormanLink,
    headers: {  
         "Content-Type": "text/html"
    },
    onload: function(response) {
      let div = document.createElement('div');
      div.innerHTML = response.responseText;
      let usage = div.querySelectorAll('.ms-dnd-progressInfoTb');
      if (usage.length > 0) {
        stormanHTML = usage[0].innerHTML;
        cl = setInterval(addLink, 200);
      }
    }
});