mirror of
https://github.com/koloml/furbooru-tagging-assistant.git
synced 2026-03-24 23:02:58 +00:00
Merge pull request #163 from koloml/feature/tag-presets
Added Tag Presets for the image upload & edit pages
This commit is contained in:
@@ -96,21 +96,16 @@ class ManifestProcessor {
|
||||
singleOrMultipleHostnames = [singleOrMultipleHostnames];
|
||||
}
|
||||
|
||||
const matchPatterReplacer = ManifestProcessor.#createHostnameReplacementReduce(singleOrMultipleHostnames);
|
||||
|
||||
this.#manifestObject.host_permissions = singleOrMultipleHostnames.map(hostname => `*://*.${hostname}/`);
|
||||
|
||||
this.#manifestObject.content_scripts?.forEach(entry => {
|
||||
entry.matches = entry.matches.reduce((resultMatches, originalMatchPattern) => {
|
||||
for (const updatedHostname of singleOrMultipleHostnames) {
|
||||
resultMatches.push(
|
||||
originalMatchPattern.replace(
|
||||
/\*:\/\/\*\.[a-z]+\.[a-z]+\//,
|
||||
`*://*.${updatedHostname}/`
|
||||
),
|
||||
);
|
||||
}
|
||||
entry.matches = entry.matches.reduce(matchPatterReplacer, []);
|
||||
|
||||
return resultMatches;
|
||||
}, []);
|
||||
if (entry.exclude_matches) {
|
||||
entry.exclude_matches = entry.exclude_matches.reduce(matchPatterReplacer, []);
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
@@ -148,6 +143,32 @@ class ManifestProcessor {
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string|(string[])} singleOrMultipleHostnames
|
||||
* @return {function(string[], string): string[]}
|
||||
*/
|
||||
static #createHostnameReplacementReduce(singleOrMultipleHostnames) {
|
||||
return (
|
||||
/**
|
||||
* @param {string[]} resultMatches
|
||||
* @param {string} originalMatchPattern
|
||||
* @return {string[]}
|
||||
*/
|
||||
(resultMatches, originalMatchPattern) => {
|
||||
for (const updatedHostname of singleOrMultipleHostnames) {
|
||||
resultMatches.push(
|
||||
originalMatchPattern.replace(
|
||||
/\*:\/\/\*\.[a-z]+\.[a-z]+\//,
|
||||
`*://*.${updatedHostname}/`
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
return resultMatches;
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -186,6 +207,7 @@ export function loadManifest(filePath) {
|
||||
/**
|
||||
* @typedef {Object} ContentScriptsEntry
|
||||
* @property {string[]} matches
|
||||
* @property {string[]} exclude_matches
|
||||
* @property {string[]|undefined} js
|
||||
* @property {string[]|undefined} css
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user