// ==UserScript== // @name JetBrains Purchased-Plugin Info // @name:ja JetBrainsの有料プラグインに関する情報 // @name:zh-CN JetBrains 付费插件信息 // @name:ru Информация о платных плагинах JetBrains // @name:fr Informations sur les plugins payants de JetBrains // @namespace http://tampermonkey.net/ // @version 0.3 // @description Get product code from JetBrains plugins // @description:zh-cn 获取 JetBrains 插件的产品代码 // @description:ru Получение кода продукта из плагинов JetBrains // @description:fr Obtenez le code du produit à partir des plugins JetBrains // @description:ja JetBrainsプラグインのプロダクトコードを取得する // @author Earmer Carey // @match *://plugins.jetbrains.com/plugin/* // @grant GM_xmlhttpRequest // @grant unsafeWindow // @license MIT // @downloadURL none // ==/UserScript== (function() { 'use strict'; // Create a container div element to display product code, attribution, and copy button let codeDiv = document.createElement("div"); codeDiv.style.position = "fixed"; codeDiv.style.top = "80px"; codeDiv.style.right = "10px"; codeDiv.style.background = "#eef"; codeDiv.style.padding = "10px"; codeDiv.style.border = "1px solid #ccc"; codeDiv.style.borderRadius = "6px"; //codeDiv.style.display = "flex"; //codeDiv.style.alignItems = "center"; codeDiv.style.fontFamily = "monospace"; // Create a span element for the product code let codeSpan = document.createElement("span"); codeSpan.style.color = "#333"; codeSpan.style.fontSize = "16px"; // Create a span element for attribution let attributionSpan = document.createElement("span"); attributionSpan.style.color = "#666"; attributionSpan.style.fontSize = "12px"; attributionSpan.textContent = "Plugin By Earmer"; // Create a button element for copying the code to clipboard let copyButton = document.createElement("button"); copyButton.style.marginLeft = "10px"; copyButton.textContent = "Copy"; copyButton.style.background = "#ddf"; copyButton.style.border = "1px solid #ccc"; copyButton.style.borderRaduis = "6px"; copyButton.addEventListener("click", function() { navigator.clipboard.writeText(codeSpan.innerText.split(" ")[2]) .then(function() { alert("roduct code copied to clipboard!"); console.log("Product code copied to clipboard"); }) .catch(function(error) { alert("Failed to copy product code, open console to know more.") console.error("Failed to copy product code: ", error); }); }); codeDiv.appendChild(codeSpan); codeDiv.appendChild(copyButton); codeDiv.appendChild(document.createElement("br")); codeDiv.appendChild(attributionSpan); document.body.appendChild(codeDiv); // extract pluginId from url let pluginId = window.location.href.split("/")[4].split("-")[0]; // request plugin info from api GM_xmlhttpRequest ({ method: "GET", url: "https://plugins.jetbrains.com/api/plugins/" + pluginId, onload: function(response) { let pluginInfo = JSON.parse(response.responseText); // check if 'purchaseInfo' and 'productCode' exist if (pluginInfo.hasOwnProperty("purchaseInfo") && pluginInfo.purchaseInfo.hasOwnProperty("productCode")) { codeSpan.innerText = "Product Code: " + pluginInfo.purchaseInfo.productCode; } else { codeSpan.innerText = "Product code not available"; } } }); })();