您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Script that enables Contentful entities to be published with ctrl+p/cmnd+p
// ==UserScript== // @name Publish Contentful entities - Keyboard shortcut // @namespace http://tampermonkey.net/ // @version 1.0.1 // @description Script that enables Contentful entities to be published with ctrl+p/cmnd+p // @author IPJT - Ian Thorslund // @match https://app.contentful.com/* // @icon https://www.google.com/s2/favicons?sz=64&domain=contentful.com // @grant window.onurlchange // @license MIT // @website https://github.com/IPJT/contentful-publish-shortcut // ==/UserScript== (function () { "use strict"; function matchScript({ url }) { removeEventListener("keydown", saveShortcut); if ( /^https:\/\/app\.contentful\.com\/spaces\/[^\/]+\/environments\/[^\/]+\/entries\//.test( url ) ) { addEventListener("keydown", saveShortcut); } } if (window.onurlchange === null) { // feature is supported window.addEventListener("urlchange", matchScript); } })(); function saveShortcut(e) { // Use Ctrl+S on Windows or Cmd+S on macOS if ((e.ctrlKey && e.key === "p") || (e.metaKey && e.key === "p")) { // Prevent the default print action e.preventDefault(); // Find and click the publish button const publishButton = document.getElementById( "status-widget-primary-action" ); if (publishButton) { publishButton.click(); console.log("Publish button clicked"); } else { console.log("Publish button not found"); } } }