Skip to content

Commit c0c3702

Browse files
authored
Fix: Unable to select text inside blob (#2458)
1 parent 2eae7e7 commit c0c3702

12 files changed

Lines changed: 149 additions & 14 deletions

dev/data/chrome-manifest-schema.json

Lines changed: 132 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,7 @@
258258
"tts",
259259
"ttsEngine",
260260
"unlimitedStorage",
261+
"userScripts",
261262
"vpnProvider",
262263
"wallpaper",
263264
"webAuthenticationProxy",
@@ -567,7 +568,12 @@
567568
},
568569
"match_about_blank": {
569570
"type": "boolean",
570-
"description": "Whether to insert the content script on about:blank and about:srcdoc.",
571+
"description": "Whether to insert the content script into about:blank and about:srcdoc.",
572+
"default": false
573+
},
574+
"match_origin_as_fallback": {
575+
"type": "boolean",
576+
"description": "Whether to insert the content script into frames with about:, data:, blob:, and filesystem: schemes whose initiator origin matches a pattern in matches. Requires the path of every matches pattern to be '*'.",
571577
"default": false
572578
}
573579
}
@@ -896,10 +902,66 @@
896902
"type": "string",
897903
"description": "In addition to the version field, which is used for update purposes, version_name can be set to a descriptive version string and will be used for display purposes if present."
898904
},
905+
"author": {
906+
"description": "The extension's author, shown in the Chrome Web Store.",
907+
"anyOf": [
908+
{
909+
"type": "string"
910+
},
911+
{
912+
"type": "object",
913+
"additionalProperties": false,
914+
"properties": {
915+
"email": {
916+
"type": "string"
917+
}
918+
}
919+
}
920+
]
921+
},
922+
"export": {
923+
"type": "object",
924+
"description": "Shared Modules: exposes this extension's resources to other extensions.",
925+
"additionalProperties": false,
926+
"properties": {
927+
"allowlist": {
928+
"type": "array",
929+
"description": "Extension IDs allowed to import resources from this Shared Module. If omitted, any extension may import.",
930+
"items": {
931+
"type": "string"
932+
}
933+
},
934+
"whitelist": {
935+
"type": "array",
936+
"description": "Deprecated alias for allowlist.",
937+
"items": {
938+
"type": "string"
939+
}
940+
}
941+
}
942+
},
899943
"chrome_settings_overrides": {},
900944
"content_pack": {},
901945
"current_locale": {},
902-
"import": {},
946+
"import": {
947+
"type": "array",
948+
"description": "Shared Modules: declares the extension IDs this extension imports resources from.",
949+
"items": {
950+
"type": "object",
951+
"required": ["id"],
952+
"additionalProperties": false,
953+
"properties": {
954+
"id": {
955+
"type": "string",
956+
"description": "The extension ID of the Shared Module to import."
957+
},
958+
"minimum_version": {
959+
"$ref": "#/definitions/version_string",
960+
"description": "The minimum version of the Shared Module required."
961+
}
962+
}
963+
}
964+
},
903965
"platforms": {},
904966
"signature": {},
905967
"spellcheck": {},
@@ -964,6 +1026,74 @@
9641026
"items": {
9651027
"$ref": "#/definitions/web_resource"
9661028
}
1029+
},
1030+
"optional_host_permissions": {
1031+
"$ref": "#/definitions/permissions",
1032+
"description": "Hosts the extension may request access to at runtime through the chrome.permissions API, rather than at install time."
1033+
},
1034+
"declarative_net_request": {
1035+
"type": "object",
1036+
"description": "Declares static rulesets for the declarativeNetRequest API, which blocks or modifies network requests without intercepting them or reading their content.",
1037+
"required": ["rule_resources"],
1038+
"additionalProperties": false,
1039+
"properties": {
1040+
"rule_resources": {
1041+
"type": "array",
1042+
"uniqueItems": true,
1043+
"items": {
1044+
"type": "object",
1045+
"required": ["id", "enabled", "path"],
1046+
"additionalProperties": false,
1047+
"properties": {
1048+
"id": {
1049+
"type": "string",
1050+
"description": "A non-empty string that uniquely identifies the ruleset. IDs starting with '_' are reserved for internal use."
1051+
},
1052+
"enabled": {
1053+
"type": "boolean",
1054+
"description": "Whether the ruleset is enabled by default."
1055+
},
1056+
"path": {
1057+
"$ref": "#/definitions/uri",
1058+
"description": "The path of the JSON ruleset, relative to the extension directory."
1059+
}
1060+
}
1061+
}
1062+
}
1063+
}
1064+
},
1065+
"side_panel": {
1066+
"type": "object",
1067+
"description": "Configures the side panel, a UI surface displayed alongside the main page (Chrome 114+).",
1068+
"additionalProperties": false,
1069+
"properties": {
1070+
"default_path": {
1071+
"$ref": "#/definitions/uri",
1072+
"description": "The path to the HTML file shown in the side panel by default."
1073+
}
1074+
}
1075+
},
1076+
"cross_origin_embedder_policy": {
1077+
"type": "object",
1078+
"description": "Sets the Cross-Origin-Embedder-Policy response header for the extension's pages, enabling cross-origin isolation features such as SharedArrayBuffer.",
1079+
"additionalProperties": false,
1080+
"properties": {
1081+
"value": {
1082+
"type": "string",
1083+
"description": "The Cross-Origin-Embedder-Policy header value, for example 'require-corp'."
1084+
}
1085+
}
1086+
},
1087+
"cross_origin_opener_policy": {
1088+
"type": "object",
1089+
"description": "Sets the Cross-Origin-Opener-Policy response header for the extension's pages.",
1090+
"additionalProperties": false,
1091+
"properties": {
1092+
"value": {
1093+
"type": "string",
1094+
"description": "The Cross-Origin-Opener-Policy header value, for example 'same-origin'."
1095+
}
1096+
}
9671097
}
9681098
},
9691099
"dependencies": {

dev/data/manifest-variants.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
"file://*/*"
4646
],
4747
"match_about_blank": true,
48+
"match_origin_as_fallback": true,
4849
"all_frames": true,
4950
"js": [
5051
"js/app/content-script-wrapper.js"

ext/js/background/backend.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -475,7 +475,7 @@ export class Backend {
475475

476476

477477
/**
478-
* @param {chrome.tabs.ZoomChangeInfo} event
478+
* @param {chrome.tabs.OnZoomChangeInfo} event
479479
*/
480480
_onZoomChange({tabId, oldZoomFactor, newZoomFactor}) {
481481
this._sendMessageTabIgnoreResponse(tabId, {action: 'applicationZoomChanged', params: {oldZoomFactor, newZoomFactor}}, {});

ext/js/background/script-manager.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@ function createContentScriptRegistrationOptions(details, id) {
125125
const options = {
126126
id: id,
127127
persistAcrossSessions: true,
128+
js: [],
128129
};
129130
if (Array.isArray(css)) {
130131
options.css = [...css];

ext/js/data/permissions-util.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ export function getAllPermissions() {
101101

102102
/**
103103
* @param {string} fieldValue
104-
* @returns {string[]}
104+
* @returns {chrome.runtime.ManifestPermission[]}
105105
*/
106106
export function getRequiredPermissionsForAnkiFieldValue(fieldValue) {
107107
const markers = getFieldMarkers(fieldValue);

ext/js/display/search-display-controller.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -588,7 +588,7 @@ export class SearchDisplayController {
588588
}
589589

590590
/**
591-
* @param {string[]} permissions
591+
* @param {chrome.runtime.ManifestPermission[]} permissions
592592
* @returns {Promise<boolean>}
593593
*/
594594
_requestPermissions(permissions) {

ext/js/pages/settings/anki-controller.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ export class AnkiController {
193193

194194
/**
195195
* @param {string} fieldValue
196-
* @returns {string[]}
196+
* @returns {chrome.runtime.ManifestPermission[]}
197197
*/
198198
getRequiredPermissions(fieldValue) {
199199
return getRequiredPermissionsForAnkiFieldValue(fieldValue);
@@ -1206,7 +1206,7 @@ class AnkiCardController {
12061206
}
12071207

12081208
/**
1209-
* @param {string[]} permissions
1209+
* @param {chrome.runtime.ManifestPermission[]} permissions
12101210
*/
12111211
async _requestPermissions(permissions) {
12121212
try {
@@ -1249,7 +1249,7 @@ class AnkiCardController {
12491249
const {inputField} = this._fieldEntries[i];
12501250
const {requiredPermission} = inputField.dataset;
12511251
if (typeof requiredPermission !== 'string') { continue; }
1252-
const requiredPermissionArray = (requiredPermission.length === 0 ? [] : requiredPermission.split(' '));
1252+
const requiredPermissionArray = /** @type {chrome.runtime.ManifestPermission[]} */ (requiredPermission.length === 0 ? [] : requiredPermission.split(' '));
12531253

12541254
let hasPermissions2 = true;
12551255
for (const permission of requiredPermissionArray) {

ext/js/pages/settings/permissions-toggle-controller.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,10 +153,10 @@ export class PermissionsToggleController {
153153

154154
/**
155155
* @param {HTMLInputElement} toggle
156-
* @returns {string[]}
156+
* @returns {chrome.runtime.ManifestPermission[]}
157157
*/
158158
_getRequiredPermissions(toggle) {
159159
const requiredPermissions = toggle.dataset.requiredPermissions;
160-
return (typeof requiredPermissions === 'string' && requiredPermissions.length > 0 ? requiredPermissions.split(' ') : []);
160+
return /** @type {chrome.runtime.ManifestPermission[]} */ (typeof requiredPermissions === 'string' && requiredPermissions.length > 0 ? requiredPermissions.split(' ') : []);
161161
}
162162
}

ext/js/pages/settings/recommended-permissions-controller.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ export class RecommendedPermissionsController {
8181
async _onOptionalPermissionsToggleChange(e) {
8282
const node = /** @type {HTMLInputElement} */ (e.currentTarget);
8383
const value = node.checked;
84+
/** @type {chrome.runtime.ManifestPermission[]} */
8485
const permissions = ['clipboardRead', 'nativeMessaging'];
8586
await setPermissionsGranted({permissions}, value);
8687
await this._updatePermissions();

package-lock.json

Lines changed: 4 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)