Automatically checks Share checkbox, focuses Tags input and enable CTRL + Enter submit on linkding bookmarks page
// ==UserScript==
// @name Auto Check Share and Focus Tags plus CTRL + Enter Save and Close
// @namespace http://tampermonkey.net/
// @version 0.3
// @description Automatically checks Share checkbox, focuses Tags input and enable CTRL + Enter submit on linkding bookmarks page
// @author Webmaster
// @match https://*/bookmarks/new*
// @grant none
// ==/UserScript==
(function() {
'use strict';
// Function to check the Share checkbox
function checkShareBox() {
const checkbox = document.getElementById('id_shared');
if (checkbox) {
checkbox.checked = true;
}
}
// Function to focus the Tags input
function focusTagsInput() {
const tagsInput = document.getElementById('id_tag_string');
if (tagsInput) {
tagsInput.focus();
}
}
// Function to handle form submission
function setupFormSubmission() {
document.addEventListener('keydown', function(event) {
if (event.ctrlKey && event.key === 'Enter') {
const submitButton = document.querySelector('input[type="submit"][value="Save and close"]');
if (submitButton) {
event.preventDefault(); // Prevent default Ctrl+Enter behavior
submitButton.click(); // Trigger the form submission
}
}
});
}
// Run when page loads
window.addEventListener('load', function() {
checkShareBox();
focusTagsInput();
setupFormSubmission();
});
// For cases where content might load dynamically
const observer = new MutationObserver(function(mutations) {
checkShareBox();
focusTagsInput();
setupFormSubmission();
});
// Start observing the document with the configured parameters
observer.observe(document, { childList: true, subtree: true });
})();
QingJ © 2025
镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址