release/0.1.0.035 #1

Merged
Ray merged 3 commits from release/0.1.0.035 into master 2024-02-04 17:12:39 +00:00
3 changed files with 68 additions and 25 deletions
Showing only changes of commit b55b10c7b3 - Show all commits

View File

@ -1,24 +1,42 @@
chrome.runtime.onInstalled.addListener(function() {
chrome.contextMenus.create({ "id": "copy_form", "title": "Copy Form", "contexts": ["editable"] });
chrome.contextMenus.create({ "id": "paste_form", "title": "Paste Form", "contexts": ["editable"], enabled: false });
chrome.contextMenus.create({ "id": "paste_form2", "title": "Paste Form (with Hidden)", "contexts": ["editable"], enabled: false });
chrome.contextMenus.create({ "id": "copy-form", "title": "Copy Form", "contexts": ["editable"] });
chrome.contextMenus.create({ "id": "paste-form", "title": "Paste Form", "contexts": ["editable"], enabled: false });
chrome.contextMenus.create({ "id": "paste-form2", "title": "Paste Form (with Hidden)", "contexts": ["editable"], enabled: false });
});
chrome.contextMenus.onClicked.addListener(function(msg, tab) {
switch (msg.menuItemId) {
case "copy_form":
case "copy-form":
copyFormContextMenu(tab);
break;
case "paste_form":
case "paste-form":
pasteFormContextMenu(tab, false);
break;
case "paste_form2":
case "paste-form2":
pasteFormContextMenu(tab, true);
break;
default: break;
}
});
chrome.commands.onCommand.addListener(function (command) {
switch (command) {
case 'copy-form':
chrome.tabs.query({ currentWindow: true, active: true }, function (tabs) {
copyFormContextMenu(tabs[0]);
});
break;
case 'paste-form':
chrome.tabs.query({ currentWindow: true, active: true }, function (tabs) {
pasteFormContextMenu(tabs[0], false);
});
break;
default: break;
}
});
@ -26,7 +44,8 @@ function copyFormContextMenu(tab) {
chrome.tabs.sendMessage(tab.id, { action: "copy" }, function(response) {
try {
chrome.storage.local.set({ 'clipboard': JSON.stringify(response) },function() {
chrome.contextMenus.update("paste_form", { enabled: true });
chrome.contextMenus.update("paste-form", { enabled: true });
chrome.contextMenus.update("paste-form2", { enabled: true });
});
} catch (err) {
// Do nothing

View File

@ -1,14 +1,14 @@
chrome.runtime.onMessage.addListener(function(request, sender, sendResponse) {
switch (request.action) {
chrome.runtime.onMessage.addListener(function(message, sender, sendResponse) {
switch (message.action) {
case "copy":
const result = copyFormElementValues(document.activeElement);
sendResponse(result);
break;
case "paste":
pasteFormElementValues(document.activeElement, request.formData, false);
pasteFormElementValues(document.activeElement, message.formData, false);
break;
case "paste2":
pasteFormElementValues(document.activeElement, request.formData, true);
pasteFormElementValues(document.activeElement, message.formData, true);
break;
default: break;
}
@ -65,6 +65,8 @@ function pasteFormElementValues(el, formData, includeHidden) {
}
}
}
writeLog("Pasted");
}
@ -147,6 +149,10 @@ function getFormElementValueSet(form, ...tagNames){
for (let i=0; i<els.length; i++) {
let newValue = null;
if (String.isNullOrWhitespace(els[i].name)) {
continue;
}
switch (els[i].type)
{
case "checkbox":

View File

@ -2,7 +2,20 @@
"manifest_version": 3,
"name": "Form Copypasta",
"description": "Copy and paste form element values. Not for distribution. Internal use only. Based on Copy Form (0.0.1.2) by Sam Larison.",
"version": "0.1.0.035",
"version": "0.1.0.075",
"icons": {
"16": "icon16.png",
"32": "icon32.png",
"48": "icon48.png",
"64": "icon64.png",
"128": "icon128.png"
},
"permissions": [
"activeTab",
"contextMenus",
"storage",
"tabs"
],
"content_scripts": [
{
"js": [
@ -19,17 +32,22 @@
"service_worker": "background.js",
"type": "module"
},
"icons": {
"16": "icon16.png",
"32": "icon32.png",
"48": "icon48.png",
"64": "icon64.png",
"128": "icon128.png"
"commands": {
"copy-form": {
"suggested_key": {
"default": "Ctrl+Shift+2",
"windows": "Ctrl+Shift+2",
"mac": "Command+Shift+2"
},
"permissions": [
"activeTab",
"contextMenus",
"storage",
"tabs"
]
"description": "Copy form"
},
"paste-form": {
"suggested_key": {
"default": "Ctrl+Shift+3",
"windows": "Ctrl+Shift+3",
"mac": "Command+Shift+3"
},
"description": "Paste form"
}
}
}