Greasy Fork

Greasy Fork is available in English.

atlassian license bulk copy

Inserts a textarea with basic license info in csv format for easy export

当前为 2024-11-27 提交的版本,查看 最新版本

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         atlassian license bulk copy
// @namespace    http://tampermonkey.net/
// @version      2024-11-27.1
// @description  Inserts a textarea with basic license info in csv format for easy export
// @author       You
// @match        https://my.atlassian.com/products/index
// @icon         https://www.google.com/s2/favicons?sz=64&domain=atlassian.com
// @grant        none
// @license      MIT
// ==/UserScript==

(function() {
    'use strict';
    window.addEventListener("load", (event) => {

        function printlicense(n, lic) {
            console.log('timeout', n, lic);
            if (n.querySelector('td span.account-name') == null
                || lic.querySelector('textarea') == null
                || lic.querySelector('#sen') == null) {
                setTimeout(printlicense, 1000, n, lic);
                return;
            }
            let name = n.querySelector('td span.account-name').textContent.trim().replaceAll(',', '');
            let description = n.querySelector('span.desc').textContent.trim().replaceAll(',', '');
            let expiry = n.querySelector('td.support-expiry-date').textContent.trim().replaceAll(',', '');
            let sen = lic.querySelector('#sen').textContent.trim().replaceAll(',', '');
            let t = lic.querySelector('textarea').textContent.trim().replaceAll(',', '');
            let line = `${name},${description},${expiry},${sen},${t}`.replaceAll('\n', '');
            document.getElementById('tsx-csv').textContent += line + '\n';
            console.log(line);
        }
        let form = document.querySelector("#your-licenses > section.product-list.show-paid > form");
        let d = document.createElement("div");
        let csv = document.createElement("textarea");
        let btn = document.createElement("button");
        csv.id = 'tsx-csv';
        csv.textContent = 'owner,app,expiry,sen,license\n';
        btn.textContent = 'copy csv';
        btn.addEventListener("click", function (e) {
            navigator.clipboard.writeText(csv.textContent);
        });
        d.appendChild(csv);
        d.appendChild(btn);
        form.after(d);
        for (let name of document.querySelectorAll("#your-licenses > section.product-list.show-paid > table > tbody > tr.headingRow")) {
            if (name.checkVisibility()) {
                name.querySelector('td > span').click();
                let lic = name.nextElementSibling;
                setTimeout(printlicense, 1000, name, lic);
            };
        };
    });
})();