mirror of
https://github.com/osnr/TabFS.git
synced 2024-05-04 06:43:14 +02:00
change TAB/textareas to TAB/inputs, add support for text inputs
This commit is contained in:
parent
07da85e36b
commit
9827b089c1
|
@ -437,16 +437,16 @@ router["/tabs/by-id/*/control"] = {
|
|||
});
|
||||
})();
|
||||
|
||||
router["/tabs/by-id/*/textareas"] = {
|
||||
router["/tabs/by-id/*/inputs"] = {
|
||||
async readdir({path}) {
|
||||
const tabId = parseInt(pathComponent(path, -2));
|
||||
// TODO: assign new IDs to textareas without them?
|
||||
const code = `Array.from(document.querySelectorAll('textarea')).map(e => e.id).filter(id => id)`
|
||||
// TODO: assign new IDs to inputs without them?
|
||||
const code = `Array.from(document.querySelectorAll('textarea, input[type=text]')).map(e => e.id).filter(id => id)`
|
||||
const ids = (await browser.tabs.executeScript(tabId, {code}))[0];
|
||||
return { entries: [".", "..", ...ids.map(id => `${id}.txt`)] };
|
||||
}
|
||||
};
|
||||
router["/tabs/by-id/*/textareas/*"] = defineFile(async path => {
|
||||
router["/tabs/by-id/*/inputs/*"] = defineFile(async path => {
|
||||
const [tabId, textareaId] = [parseInt(pathComponent(path, -3)), pathComponent(path, -1).slice(0, -4)];
|
||||
const code = `document.getElementById('${textareaId}').value`;
|
||||
const textareaValue = (await browser.tabs.executeScript(tabId, {code}))[0];
|
||||
|
|
Loading…
Reference in a new issue