mirror of
https://github.com/osnr/TabFS.git
synced 2024-05-02 22:03:10 +02:00
read/write textareas
This commit is contained in:
parent
5f6cad2c71
commit
08885dc990
|
@ -439,6 +439,26 @@ router["/tabs/by-id/*/active"] = {
|
||||||
});
|
});
|
||||||
})();
|
})();
|
||||||
|
|
||||||
|
router["/tabs/by-id/*/textareas"] = {
|
||||||
|
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)`
|
||||||
|
const ids = (await browser.tabs.executeScript(tabId, {code}))[0];
|
||||||
|
return { entries: [".", "..", ...ids.map(id => `${id}.txt`)] };
|
||||||
|
}
|
||||||
|
};
|
||||||
|
router["/tabs/by-id/*/textareas/*"] = 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];
|
||||||
|
return textareaValue;
|
||||||
|
}, async (path, buf) => {
|
||||||
|
const [tabId, textareaId] = [parseInt(pathComponent(path, -3)), pathComponent(path, -1).slice(0, -4)];
|
||||||
|
const code = `document.getElementById('${textareaId}').value = unescape('${escape(buf)}')`;
|
||||||
|
await browser.tabs.executeScript(tabId, {code});
|
||||||
|
});
|
||||||
|
|
||||||
router["/tabs/by-title"] = {
|
router["/tabs/by-title"] = {
|
||||||
getattr() {
|
getattr() {
|
||||||
return {
|
return {
|
||||||
|
|
Loading…
Reference in a new issue