mirror of
https://github.com/NohamR/safari-internal-js.git
synced 2026-10-10 18:39:42 +00:00
Add 27.0 js src
This commit is contained in:
0
27.0/html/.gitkeep
Normal file
0
27.0/html/.gitkeep
Normal file
39
27.0/js/automation/WDElementAttribute.js
Normal file
39
27.0/js/automation/WDElementAttribute.js
Normal file
@@ -0,0 +1,39 @@
|
||||
//# sourceURL=__InjectedScript_WDElementAttribute.js
|
||||
function(element){"use strict";var utils={};utils.enclosingNodeOrSelfMatchingPredicate=function(targetNode,predicate){for(let node=targetNode;node&&node!==targetNode.getRootNode();node=node.parentNode)
|
||||
if(predicate(node))
|
||||
return node;return null;}
|
||||
utils.nodeIsElement=function(node){return!!node&&node.nodeType===Node.ELEMENT_NODE;}
|
||||
utils.parentElementForElement=function(element){if(!element)
|
||||
return null;return utils.enclosingNodeOrSelfMatchingPredicate(element.parentNode,utils.nodeIsElement);}
|
||||
utils.cascadedStylePropertyForElement=function(element,property){if(!element||!property)
|
||||
return null;let computedStyle=window.getComputedStyle(element);let computedStyleProperty=computedStyle.getPropertyValue(property);if(computedStyleProperty&&computedStyleProperty!=="inherit")
|
||||
return computedStyleProperty;
|
||||
|
||||
let parentElement=utils.parentElementForElement(element);return utils.cascadedStylePropertyForElement(parentElement,property);}
|
||||
utils.isShown=function(element){function enclosingElementOrSelfMatchingPredicate(targetElement,predicate){for(let element=targetElement;element&&element!==targetElement.getRootNode();element=utils.parentElementForElement(element))
|
||||
if(predicate(element))
|
||||
return element;return null;}
|
||||
function elementSubtreeHasNonZeroDimensions(element){let boundingBox=element.getBoundingClientRect();if(boundingBox.width>0&&boundingBox.height>0)
|
||||
return true;if(element.tagName.toUpperCase()==="PATH"&&boundingBox.width+boundingBox.height>0){let strokeWidth=utils.cascadedStylePropertyForElement(element,"stroke-width");return!!strokeWidth&&(parseInt(strokeWidth,10)>0);}
|
||||
let cascadedOverflow=utils.cascadedStylePropertyForElement(element,"overflow");if(cascadedOverflow==="hidden")
|
||||
return false;
|
||||
return Array.from(element.childNodes).some((childNode)=>{if(childNode.nodeType===Node.TEXT_NODE)
|
||||
return true;if(utils.nodeIsElement(childNode))
|
||||
return elementSubtreeHasNonZeroDimensions(childNode);return false;});}
|
||||
function elementOverflowsContainer(element){let cascadedOverflow=utils.cascadedStylePropertyForElement(element,"overflow");if(cascadedOverflow!=="hidden")
|
||||
return false;return true;}
|
||||
function isElementSubtreeHiddenByOverflow(element){if(!element)
|
||||
return false;if(!elementOverflowsContainer(element))
|
||||
return false;if(!element.childNodes.length)
|
||||
return false;return Array.from(element.childNodes).every((childNode)=>{if(!utils.nodeIsElement(childNode))
|
||||
return true;if(!elementSubtreeHasNonZeroDimensions(childNode))
|
||||
return true;return isElementSubtreeHiddenByOverflow(childNode);});}
|
||||
if(!(element instanceof Element))
|
||||
throw new Error("Cannot check the displayedness of a non-Element argument.");switch(element.tagName.toUpperCase()){case"BODY":return true;case"SCRIPT":case"NOSCRIPT":return false;case"OPTGROUP":case"OPTION":let enclosingSelectElement=utils.enclosingNodeOrSelfMatchingPredicate(element,(e)=>e.tagName.toUpperCase()==="SELECT");return utils.isShown(enclosingSelectElement);case"INPUT":if(element.type==="hidden")
|
||||
return false;break;case"MAP":default:break;}
|
||||
if(utils.cascadedStylePropertyForElement(element,"visibility")!=="visible")
|
||||
return false;let hasAncestorWithZeroOpacity=!!enclosingElementOrSelfMatchingPredicate(element,(e)=>{return Number(utils.cascadedStylePropertyForElement(e,"opacity"))===0;});let hasAncestorWithDisplayNone=!!enclosingElementOrSelfMatchingPredicate(element,(e)=>{return utils.cascadedStylePropertyForElement(e,"display")==="none";});if(hasAncestorWithZeroOpacity||hasAncestorWithDisplayNone)
|
||||
return false;if(!elementSubtreeHasNonZeroDimensions(element))
|
||||
return false;if(isElementSubtreeHiddenByOverflow(element))
|
||||
return false;return true;}
|
||||
return utils.isShown(element);}
|
||||
13
27.0/js/automation/WDElementDisplayed.js
Normal file
13
27.0/js/automation/WDElementDisplayed.js
Normal file
@@ -0,0 +1,13 @@
|
||||
//# sourceURL=__InjectedScript_WDElementDisplayed.js
|
||||
function fetchTagNameAndAttributesOfElement(element) {
|
||||
"use strict";
|
||||
let tagName = element.tagName.toUpperCase();
|
||||
let attributes = {};
|
||||
for (let i = 0; i < element.attributes.length; ++i) {
|
||||
let name = element.attributes[i].name.toLowerCase();
|
||||
let value = element.attributes[i].value;
|
||||
if (!value.length) value = null;
|
||||
attributes[name] = value;
|
||||
}
|
||||
return { tagName, attributes };
|
||||
}
|
||||
38
27.0/js/automation/WDElementFetchAttributes.js
Normal file
38
27.0/js/automation/WDElementFetchAttributes.js
Normal file
@@ -0,0 +1,38 @@
|
||||
//# sourceURL=__InjectedScript_WDElementFetchAttributes.js
|
||||
function enterFullscreen() {
|
||||
let callback = arguments[0];
|
||||
if (!document.fullscreenEnabled) {
|
||||
callback(false);
|
||||
return;
|
||||
}
|
||||
if (document.fullscreenElement) {
|
||||
callback(true);
|
||||
return;
|
||||
}
|
||||
let fullscreenChangeListener, fullscreenErrorListener;
|
||||
fullscreenChangeListener = (e) => {
|
||||
if (e.target !== document.documentElement) return;
|
||||
if (!document.fullscreenElement) return;
|
||||
document.removeEventListener("fullscreenchange", fullscreenChangeListener);
|
||||
document.documentElement.removeEventListener(
|
||||
"fullscreenerror",
|
||||
fullscreenErrorListener,
|
||||
);
|
||||
callback(true);
|
||||
};
|
||||
fullscreenErrorListener = (e) => {
|
||||
if (e.target !== document.documentElement) return;
|
||||
document.removeEventListener("fullscreenchange", fullscreenChangeListener);
|
||||
document.documentElement.removeEventListener(
|
||||
"fullscreenerror",
|
||||
fullscreenErrorListener,
|
||||
);
|
||||
callback(!!document.fullscreenElement);
|
||||
};
|
||||
document.addEventListener("fullscreenchange", fullscreenChangeListener);
|
||||
document.documentElement.addEventListener(
|
||||
"fullscreenerror",
|
||||
fullscreenErrorListener,
|
||||
);
|
||||
document.documentElement.requestFullscreen();
|
||||
}
|
||||
82
27.0/js/automation/WDEnterFullscreen.js
Normal file
82
27.0/js/automation/WDEnterFullscreen.js
Normal file
@@ -0,0 +1,82 @@
|
||||
//# sourceURL=__InjectedScript_WDEnterFullscreen.js
|
||||
function(strategy,ancestorElement,query,firstResultOnly,timeoutDuration,callback){"use strict";var utils={};utils.enclosingNodeOrSelfMatchingPredicate=function(targetNode,predicate){for(let node=targetNode;node&&node!==targetNode.getRootNode();node=node.parentNode)
|
||||
if(predicate(node))
|
||||
return node;return null;}
|
||||
utils.nodeIsElement=function(node){return!!node&&node.nodeType===Node.ELEMENT_NODE;}
|
||||
utils.parentElementForElement=function(element){if(!element)
|
||||
return null;return utils.enclosingNodeOrSelfMatchingPredicate(element.parentNode,utils.nodeIsElement);}
|
||||
utils.cascadedStylePropertyForElement=function(element,property){if(!element||!property)
|
||||
return null;let computedStyle=window.getComputedStyle(element);let computedStyleProperty=computedStyle.getPropertyValue(property);if(computedStyleProperty&&computedStyleProperty!=="inherit")
|
||||
return computedStyleProperty;
|
||||
|
||||
let parentElement=utils.parentElementForElement(element);return utils.cascadedStylePropertyForElement(parentElement,property);}
|
||||
utils.isShown=function(element){function enclosingElementOrSelfMatchingPredicate(targetElement,predicate){for(let element=targetElement;element&&element!==targetElement.getRootNode();element=utils.parentElementForElement(element))
|
||||
if(predicate(element))
|
||||
return element;return null;}
|
||||
function elementSubtreeHasNonZeroDimensions(element){let boundingBox=element.getBoundingClientRect();if(boundingBox.width>0&&boundingBox.height>0)
|
||||
return true;if(element.tagName.toUpperCase()==="PATH"&&boundingBox.width+boundingBox.height>0){let strokeWidth=utils.cascadedStylePropertyForElement(element,"stroke-width");return!!strokeWidth&&(parseInt(strokeWidth,10)>0);}
|
||||
let cascadedOverflow=utils.cascadedStylePropertyForElement(element,"overflow");if(cascadedOverflow==="hidden")
|
||||
return false;
|
||||
return Array.from(element.childNodes).some((childNode)=>{if(childNode.nodeType===Node.TEXT_NODE)
|
||||
return true;if(utils.nodeIsElement(childNode))
|
||||
return elementSubtreeHasNonZeroDimensions(childNode);return false;});}
|
||||
function elementOverflowsContainer(element){let cascadedOverflow=utils.cascadedStylePropertyForElement(element,"overflow");if(cascadedOverflow!=="hidden")
|
||||
return false;return true;}
|
||||
function isElementSubtreeHiddenByOverflow(element){if(!element)
|
||||
return false;if(!elementOverflowsContainer(element))
|
||||
return false;if(!element.childNodes.length)
|
||||
return false;return Array.from(element.childNodes).every((childNode)=>{if(!utils.nodeIsElement(childNode))
|
||||
return true;if(!elementSubtreeHasNonZeroDimensions(childNode))
|
||||
return true;return isElementSubtreeHiddenByOverflow(childNode);});}
|
||||
if(!(element instanceof Element))
|
||||
throw new Error("Cannot check the displayedness of a non-Element argument.");switch(element.tagName.toUpperCase()){case"BODY":return true;case"SCRIPT":case"NOSCRIPT":return false;case"OPTGROUP":case"OPTION":let enclosingSelectElement=utils.enclosingNodeOrSelfMatchingPredicate(element,(e)=>e.tagName.toUpperCase()==="SELECT");return utils.isShown(enclosingSelectElement);case"INPUT":if(element.type==="hidden")
|
||||
return false;break;case"MAP":default:break;}
|
||||
if(utils.cascadedStylePropertyForElement(element,"visibility")!=="visible")
|
||||
return false;let hasAncestorWithZeroOpacity=!!enclosingElementOrSelfMatchingPredicate(element,(e)=>{return Number(utils.cascadedStylePropertyForElement(e,"opacity"))===0;});let hasAncestorWithDisplayNone=!!enclosingElementOrSelfMatchingPredicate(element,(e)=>{return utils.cascadedStylePropertyForElement(e,"display")==="none";});if(hasAncestorWithZeroOpacity||hasAncestorWithDisplayNone)
|
||||
return false;if(!elementSubtreeHasNonZeroDimensions(element))
|
||||
return false;if(isElementSubtreeHiddenByOverflow(element))
|
||||
return false;return true;}
|
||||
utils.getText=function(element){var lines=[];function appendLinesFromTextNode(textNode,whitespace,textTransform){let text=textNode.nodeValue.replace(/[\u200b\u200e\u200f]/g,'');text=text.replace(/(\r\n|\r|\n)/g,'\n');let collapseAll=true;switch(whitespace){case"normal":case"nowrap":text=text.replace(/\n/g,' ');break;case"pre":case"pre-wrap":text=text.replace(/[ \f\t\v\u2028\u2029]/g,'\xa0');collapseAll=false;break;}
|
||||
if(collapseAll){text=text.replace(/[\ \f\t\v\u2028\u2029]+/g,' ');}
|
||||
switch(textTransform){case"capitalize":text=text.replace(/(^|[^\d\p{L}\p{S}])([\p{Ll}|\p{S}])/gu,function(){return arguments[1]+arguments[2].toUpperCase();});break;case"uppercase":text=text.toUpperCase();break;case"lowercase":text=text.toLowerCase();break;}
|
||||
let currentLine=lines.pop()||'';if(currentLine.endsWith(' ')&&text.startsWith(' '))
|
||||
text=text.substr(1);lines.push(currentLine+text);}
|
||||
function appendLinesFromNode(node,shown,whitespace,textTransform){switch(node.nodeType){case Node.TEXT_NODE:if(shown)
|
||||
appendLinesFromTextNode(node,whitespace,textTransform);break;case Node.ELEMENT_NODE:if(node.tagName.toUpperCase()=="SLOT"){let parentNode=node;while(parentNode.parentNode)
|
||||
parentNode=parentNode.parentNode;if(parentNode instanceof ShadowRoot){Array.from(node.assignedNodes()).forEach((childNode)=>{appendLinesFromNode(childNode,shown,whitespace,textTransform);});return;}}
|
||||
appendLinesFromElement(node);break;}}
|
||||
function appendLines(element){function currentLine(){return lines[lines.length-1]||'';}
|
||||
let isTableCell=false,display=null,isBlock=false;if(element.tagName.toUpperCase()==="BR")
|
||||
lines.push('');else{isTableCell=element.tagName.toUpperCase()==="TD";display=utils.cascadedStylePropertyForElement(element,"display");isBlock=!isTableCell&&!(display==="inline"||display==="inline-block"||display==="inline-table"||display==="none"||display==="table-cell"||display==="table-column"||display==="table-column-group");let previousElementSibling=element.previousElementSibling;let previousDisplay=previousElementSibling?utils.cascadedStylePropertyForElement(previousElementSibling,"display"):'';let elementFloat=utils.cascadedStylePropertyForElement(element,"float")||utils.cascadedStylePropertyForElement(element,"cssFloat");let runIntoThis=previousDisplay=="run-in"&&elementFloat=="none";if(isBlock&&!runIntoThis&&/^[\s\xa0]*$/.test(currentLine()))
|
||||
lines.push('');}
|
||||
let shown=utils.isShown(element);let whitespace=null,textTransform=null;if(shown){whitespace=utils.cascadedStylePropertyForElement(element,"white-space");textTransform=utils.cascadedStylePropertyForElement(element,"text-transform");}
|
||||
Array.from(element.childNodes).forEach((childNode)=>{if(!childNode.assignedSlot)
|
||||
appendLinesFromNode(childNode,shown,whitespace,textTransform);});let line=currentLine();if((isTableCell||display=="table-cell")&&line&&line.endsWith(' '))
|
||||
lines[lines.length-1]+=' ';if(isBlock&&display!="run-in"&&/^[\s\xa0]*$/.test(line))
|
||||
lines.push('');}
|
||||
function appendLinesFromElement(element){if(element.shadowRoot){Array.from(element.shadowRoot.childNodes).forEach((childNode)=>{appendLinesFromNode(childNode,true,null,null);});}
|
||||
appendLines(element);}
|
||||
appendLinesFromElement(element);lines=lines.map((str)=>str.replace(/^[^\S\xa0]+|[^\S\xa0]+$/g,''));let trimmed=lines.join('\n').replace(/^[^\S\xa0]+|[^\S\xa0]+$/g,'');return trimmed.replace(/\xa0/g,' ');}
|
||||
ancestorElement=ancestorElement||document;switch(strategy){case"id":strategy="css selector";query="[id=\""+escape(query)+"\"]";break;case"name":strategy="css selector";query="[name=\""+escape(query)+"\"]";break;}
|
||||
switch(strategy){case"css selector":case"link text":case"partial link text":case"tag name":case"class name":case"xpath":break;default:
|
||||
throw{name:"InvalidParameter",message:("Unsupported locator strategy: "+strategy+".")};}
|
||||
function escape(string){return string.replace(/\\/g,"\\\\").replace(/"/g,"\\\"");}
|
||||
function tryToFindNode(){try{switch(strategy){case"css selector":if(firstResultOnly)
|
||||
return ancestorElement.querySelector(query)||null;return Array.from(ancestorElement.querySelectorAll(query));case"link text":let linkTextResult=[];for(let link of ancestorElement.querySelectorAll("a")){if(utils.getText(link).trim()==query){linkTextResult.push(link);if(firstResultOnly)
|
||||
break;}}
|
||||
if(firstResultOnly)
|
||||
return linkTextResult[0]||null;return linkTextResult;case"partial link text":let partialLinkResult=[];for(let link of ancestorElement.querySelectorAll("a")){if(utils.getText(link).includes(query)){partialLinkResult.push(link);if(firstResultOnly)
|
||||
break;}}
|
||||
if(firstResultOnly)
|
||||
return partialLinkResult[0]||null;return partialLinkResult;case"tag name":let tagNameResult=ancestorElement.getElementsByTagName(query);if(firstResultOnly)
|
||||
return tagNameResult[0]||null;return Array.from(tagNameResult);case"class name":let classNameResult=ancestorElement.getElementsByClassName(query);if(firstResultOnly)
|
||||
return classNameResult[0]||null;return Array.from(classNameResult);case"xpath":if(firstResultOnly){let xpathResult=document.evaluate(query,ancestorElement,null,XPathResult.FIRST_ORDERED_NODE_TYPE,null);if(!xpathResult)
|
||||
return null;return xpathResult.singleNodeValue;}
|
||||
let xpathResult=document.evaluate(query,ancestorElement,null,XPathResult.ORDERED_NODE_SNAPSHOT_TYPE,null);if(!xpathResult||!xpathResult.snapshotLength)
|
||||
return[];let arrayResult=[];for(let i=0;i<xpathResult.snapshotLength;++i)
|
||||
arrayResult.push(xpathResult.snapshotItem(i));return arrayResult;}}catch(error){
|
||||
throw{name:"InvalidSelector",message:error.message};}}
|
||||
const pollInterval=50;let pollUntil=performance.now()+timeoutDuration;function pollForNode(){let result=tryToFindNode();if(typeof result==="string"||result instanceof Node||(result instanceof Array&&result.length)){callback(result);return;}
|
||||
let durationRemaining=pollUntil-performance.now();if(durationRemaining<pollInterval){callback(firstResultOnly?null:[]);return;}
|
||||
setTimeout(pollForNode,pollInterval);}
|
||||
pollForNode();}
|
||||
14
27.0/js/automation/WDFindNodes.js
Normal file
14
27.0/js/automation/WDFindNodes.js
Normal file
@@ -0,0 +1,14 @@
|
||||
//# sourceURL=__InjectedScript_WDFindNodes.js
|
||||
function(element){"use strict";function isEditable(element){if(element.disabled||element.readOnly)
|
||||
return false;if(element instanceof HTMLTextAreaElement)
|
||||
return true;if(element.isContentEditable)
|
||||
return true;if(element.tagName.toUpperCase()!="INPUT")
|
||||
return false;switch(element.type){case"color":case"date":case"datetime-local":case"email":case"file":case"month":case"number":case"password":case"range":case"search":case"tel":case"text":case"time":case"url":case"week":return true;}
|
||||
return false;}
|
||||
if(!isEditable(element))
|
||||
throw{name:"InvalidElementState",message:"Element must be user-editable in order to clear."};if(element.isContentEditable){if(element.innerHTML==="")
|
||||
return;element.focus();element.innerHTML="";element.blur();return;}
|
||||
function isResettableElementEmpty(element){if(element instanceof HTMLInputElement&&element.type=="file")
|
||||
return element.files.length==0;return element.value==="";}
|
||||
if(element.validity.valid&&isResettableElementEmpty(element))
|
||||
return;element.focus();element.value="";var event=document.createEvent("Event");event.initEvent("change",true,true);element.dispatchEvent(event);element.blur();}
|
||||
3
27.0/js/automation/WDFormElementClear.js
Normal file
3
27.0/js/automation/WDFormElementClear.js
Normal file
@@ -0,0 +1,3 @@
|
||||
//# sourceURL=__InjectedScript_WDFormElementClear.js
|
||||
function(element){for(let currentElement=element;currentElement&¤tElement!==document;currentElement=currentElement.parentNode){if(!(currentElement instanceof HTMLFormElement))
|
||||
continue;currentElement.submit();break;}}
|
||||
1
27.0/js/automation/WDFormSubmit.js
Normal file
1
27.0/js/automation/WDFormSubmit.js
Normal file
@@ -0,0 +1 @@
|
||||
//# sourceURL=__InjectedScript_WDFormSubmit.js
|
||||
410
27.0/js/automation/WebAutomationSessionProxy.js
Normal file
410
27.0/js/automation/WebAutomationSessionProxy.js
Normal file
@@ -0,0 +1,410 @@
|
||||
//# sourceURL=__InjectedScript_WebAutomationSessionProxy.js
|
||||
(function (sessionIdentifier, evaluate, createUUID, isValidNodeIdentifier) {
|
||||
const sessionNodePropertyName = "session-node-" + sessionIdentifier;
|
||||
let AutomationSessionProxy = class AutomationSessionProxy {
|
||||
constructor() {
|
||||
this._nodeToIdMap = new Map();
|
||||
this._idToNodeMap = new Map();
|
||||
}
|
||||
evaluateJavaScriptFunction(
|
||||
functionString,
|
||||
argumentStrings,
|
||||
expectsImplicitCallbackArgument,
|
||||
forceUserGesture,
|
||||
frameID,
|
||||
callbackID,
|
||||
resultCallback,
|
||||
callbackTimeout,
|
||||
) {
|
||||
this._execute(
|
||||
functionString,
|
||||
argumentStrings,
|
||||
expectsImplicitCallbackArgument,
|
||||
callbackTimeout,
|
||||
)
|
||||
.then((result) => {
|
||||
resultCallback(frameID, callbackID, this._jsonStringify(result));
|
||||
})
|
||||
.catch((error) => {
|
||||
resultCallback(frameID, callbackID, error);
|
||||
});
|
||||
}
|
||||
evaluateBidiScript(
|
||||
expression,
|
||||
awaitPromise,
|
||||
maxObjectDepth,
|
||||
frameID,
|
||||
callbackID,
|
||||
resultCallback,
|
||||
callbackTimeout,
|
||||
) {
|
||||
this._executeBidiScript(
|
||||
expression,
|
||||
awaitPromise,
|
||||
maxObjectDepth,
|
||||
callbackTimeout,
|
||||
)
|
||||
.then((result) => {
|
||||
resultCallback(frameID, callbackID, JSON.stringify(result));
|
||||
})
|
||||
.catch((error) => {
|
||||
resultCallback(frameID, callbackID, error);
|
||||
});
|
||||
}
|
||||
nodeForIdentifier(identifier) {
|
||||
this._clearStaleNodes();
|
||||
try {
|
||||
return this._nodeForIdentifier(identifier);
|
||||
} catch (error) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
_execute(
|
||||
functionString,
|
||||
argumentStrings,
|
||||
expectsImplicitCallbackArgument,
|
||||
callbackTimeout,
|
||||
) {
|
||||
let timeoutPromise;
|
||||
let timeoutIdentifier = 0;
|
||||
if (callbackTimeout >= 0) {
|
||||
timeoutPromise = new Promise((resolve, reject) => {
|
||||
timeoutIdentifier = setTimeout(() => {
|
||||
reject({
|
||||
name: "JavaScriptTimeout",
|
||||
message: `script timed out after ${callbackTimeout}ms`,
|
||||
});
|
||||
}, callbackTimeout);
|
||||
});
|
||||
}
|
||||
let promise = new Promise((resolve, reject) => {
|
||||
let lines = functionString.split("\n");
|
||||
let prefixLines = [];
|
||||
while (lines && lines[0].startsWith("//")) {
|
||||
prefixLines.push(lines.shift());
|
||||
}
|
||||
functionString = lines.join("\n");
|
||||
let prefix = prefixLines.join("\n");
|
||||
if (prefix) prefix += "\n";
|
||||
let functionValue = evaluate(prefix + "(async " + functionString + ")");
|
||||
if (typeof functionValue !== "function")
|
||||
reject(new TypeError("Script did not evaluate to a function."));
|
||||
this._clearStaleNodes();
|
||||
let argumentValues = argumentStrings.map(this._jsonParse, this);
|
||||
if (expectsImplicitCallbackArgument) argumentValues.push(resolve);
|
||||
let resultPromise = functionValue.apply(null, argumentValues);
|
||||
let promises = [resultPromise];
|
||||
if (timeoutPromise) promises.push(timeoutPromise);
|
||||
Promise.race(promises)
|
||||
.then((result) => {
|
||||
if (!expectsImplicitCallbackArgument) {
|
||||
resolve(result);
|
||||
}
|
||||
})
|
||||
.catch((error) => {
|
||||
reject(error);
|
||||
});
|
||||
});
|
||||
|
||||
let promises = [promise];
|
||||
if (timeoutPromise) promises.push(timeoutPromise);
|
||||
return Promise.race(promises).finally(() => {
|
||||
if (timeoutIdentifier) {
|
||||
clearTimeout(timeoutIdentifier);
|
||||
}
|
||||
});
|
||||
}
|
||||
_executeBidiScript(
|
||||
expression,
|
||||
awaitPromise,
|
||||
maxObjectDepth,
|
||||
callbackTimeout,
|
||||
) {
|
||||
let timeoutPromise;
|
||||
let timeoutIdentifier = 0;
|
||||
if (callbackTimeout >= 0) {
|
||||
timeoutPromise = new Promise((resolve, reject) => {
|
||||
timeoutIdentifier = setTimeout(() => {
|
||||
reject({
|
||||
name: "JavaScriptTimeout",
|
||||
message: `script timed out after ${callbackTimeout}ms`,
|
||||
});
|
||||
}, callbackTimeout);
|
||||
});
|
||||
}
|
||||
let promise = new Promise((resolve, reject) => {
|
||||
try {
|
||||
let result = globalThis.eval(expression);
|
||||
if (awaitPromise && result && typeof result.then === "function") {
|
||||
result.then(
|
||||
(value) => {
|
||||
let serializedValue = this.serializeBidiRemoteValue(
|
||||
value,
|
||||
maxObjectDepth,
|
||||
);
|
||||
resolve({ success: true, result: serializedValue });
|
||||
},
|
||||
(error) => {
|
||||
reject({
|
||||
success: false,
|
||||
error: {
|
||||
name: error.name,
|
||||
message: error.message,
|
||||
stack: error.stack,
|
||||
},
|
||||
});
|
||||
},
|
||||
);
|
||||
} else {
|
||||
let serializedValue = this.serializeBidiRemoteValue(
|
||||
result,
|
||||
maxObjectDepth,
|
||||
);
|
||||
resolve({ success: true, result: serializedValue });
|
||||
}
|
||||
} catch (error) {
|
||||
reject({
|
||||
success: false,
|
||||
error: {
|
||||
name: error.name,
|
||||
message: error.message,
|
||||
stack: error.stack,
|
||||
},
|
||||
});
|
||||
}
|
||||
});
|
||||
let promises = [promise];
|
||||
if (timeoutPromise) promises.push(timeoutPromise);
|
||||
return Promise.race(promises).finally(() => {
|
||||
if (timeoutIdentifier) {
|
||||
clearTimeout(timeoutIdentifier);
|
||||
}
|
||||
});
|
||||
}
|
||||
_jsonParse(string) {
|
||||
if (!string) return undefined;
|
||||
return JSON.parse(string, (key, value) =>
|
||||
this._reviveJSONValue(key, value),
|
||||
);
|
||||
}
|
||||
_jsonStringify(value) {
|
||||
return JSON.stringify(this._jsonClone(value));
|
||||
}
|
||||
_reviveJSONValue(key, value) {
|
||||
if (value && typeof value === "object" && value[sessionNodePropertyName])
|
||||
return this._nodeForIdentifier(value[sessionNodePropertyName]);
|
||||
return value;
|
||||
}
|
||||
_isCollection(value) {
|
||||
switch (Object.prototype.toString.call(value)) {
|
||||
case "[object Arguments]":
|
||||
case "[object Array]":
|
||||
case "[object FileList]":
|
||||
case "[object HTMLAllCollection]":
|
||||
case "[object HTMLCollection]":
|
||||
case "[object HTMLFormControlsCollection]":
|
||||
case "[object HTMLOptionsCollection]":
|
||||
case "[object NodeList]":
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
_checkCyclic(value, stack = []) {
|
||||
function isCyclic(value, proxy, stack = []) {
|
||||
if (value === undefined || value === null) return false;
|
||||
if (
|
||||
typeof value === "boolean" ||
|
||||
typeof value === "number" ||
|
||||
typeof value === "string"
|
||||
)
|
||||
return false;
|
||||
if (value instanceof Node) return false;
|
||||
if (stack.includes(value)) return true;
|
||||
if (proxy._isCollection(value)) {
|
||||
stack.push(value);
|
||||
for (let i = 0; i < value.length; i++) {
|
||||
if (isCyclic(value[i], proxy, stack)) return true;
|
||||
}
|
||||
stack.pop();
|
||||
return false;
|
||||
}
|
||||
stack.push(value);
|
||||
for (let property in value) {
|
||||
if (isCyclic(value[property], proxy, stack)) return true;
|
||||
}
|
||||
stack.pop();
|
||||
return false;
|
||||
}
|
||||
if (isCyclic(value, this))
|
||||
throw new TypeError("cannot serialize cyclic structures.");
|
||||
}
|
||||
_jsonClone(value) {
|
||||
if (value === undefined || value === null) return null;
|
||||
if (
|
||||
typeof value === "boolean" ||
|
||||
typeof value === "number" ||
|
||||
typeof value === "string"
|
||||
)
|
||||
return value;
|
||||
if (this._isCollection(value)) {
|
||||
this._checkCyclic(value);
|
||||
return [...value].map((item) => this._jsonClone(item));
|
||||
}
|
||||
if (value instanceof Node) return this._createNodeHandle(value);
|
||||
if (typeof value.toJSON === "function") return value.toJSON();
|
||||
let customObject = {};
|
||||
for (let property in value) {
|
||||
this._checkCyclic(value);
|
||||
customObject[property] = this._jsonClone(value[property]);
|
||||
}
|
||||
return customObject;
|
||||
}
|
||||
_createNodeHandle(node) {
|
||||
if (node.ownerDocument !== window.document || !node.isConnected)
|
||||
throw {
|
||||
name: "NodeNotFound",
|
||||
message: "Stale element found when trying to create the node handle",
|
||||
};
|
||||
return { [sessionNodePropertyName]: this._identifierForNode(node) };
|
||||
}
|
||||
_nodeForIdentifier(identifier) {
|
||||
if (!isValidNodeIdentifier(identifier))
|
||||
throw {
|
||||
name: "InvalidNodeIdentifier",
|
||||
message: "Node identifier '" + identifier + "' is invalid",
|
||||
};
|
||||
let node = this._idToNodeMap.get(identifier);
|
||||
if (node) return node;
|
||||
throw {
|
||||
name: "NodeNotFound",
|
||||
message: "Node with identifier '" + identifier + "' was not found",
|
||||
};
|
||||
}
|
||||
_identifierForNode(node) {
|
||||
let identifier = this._nodeToIdMap.get(node);
|
||||
if (identifier) return identifier;
|
||||
identifier = "node-" + createUUID();
|
||||
this._nodeToIdMap.set(node, identifier);
|
||||
this._idToNodeMap.set(identifier, node);
|
||||
return identifier;
|
||||
}
|
||||
_clearStaleNodes() {
|
||||
for (var [node, identifier] of this._nodeToIdMap) {
|
||||
const rootNode = node.getRootNode({ composed: true });
|
||||
if (rootNode !== document) {
|
||||
this._nodeToIdMap.delete(node);
|
||||
this._idToNodeMap.delete(identifier);
|
||||
}
|
||||
}
|
||||
}
|
||||
serializeBidiRemoteValue(
|
||||
value,
|
||||
maxObjectDepth = 1,
|
||||
depth = 0,
|
||||
visitedObjects = new Set(),
|
||||
) {
|
||||
if (value === null) return { type: "null" };
|
||||
if (value === undefined) return { type: "undefined" };
|
||||
if (typeof value === "boolean") return { type: "boolean", value: value };
|
||||
if (typeof value === "string") return { type: "string", value: value };
|
||||
if (typeof value === "number") {
|
||||
if (isNaN(value)) return { type: "number", value: "NaN" };
|
||||
if (value === Infinity) return { type: "number", value: "Infinity" };
|
||||
if (value === -Infinity) return { type: "number", value: "-Infinity" };
|
||||
if (Object.is(value, -0)) return { type: "number", value: "-0" };
|
||||
return { type: "number", value: value };
|
||||
}
|
||||
if (typeof value === "bigint")
|
||||
return { type: "bigint", value: value.toString() };
|
||||
if (typeof value === "symbol") return { type: "symbol" };
|
||||
if (typeof value === "function") return { type: "function" };
|
||||
if (typeof value === "object" || typeof value === "function") {
|
||||
if (value === window)
|
||||
return {
|
||||
type: "window",
|
||||
value: { context: "context-id-placeholder" },
|
||||
};
|
||||
if (value instanceof Date)
|
||||
return { type: "date", value: value.toISOString() };
|
||||
if (value instanceof RegExp)
|
||||
return {
|
||||
type: "regexp",
|
||||
value: { pattern: value.source, flags: value.flags },
|
||||
};
|
||||
if (value instanceof Error) return { type: "error" };
|
||||
if (value instanceof Promise) return { type: "promise" };
|
||||
if (value instanceof Map) {
|
||||
let entries = [];
|
||||
for (let [k, v] of value.entries()) {
|
||||
entries.push({
|
||||
key: this.serializeBidiRemoteValue(
|
||||
k,
|
||||
maxObjectDepth,
|
||||
depth + 1,
|
||||
visitedObjects,
|
||||
),
|
||||
value: this.serializeBidiRemoteValue(
|
||||
v,
|
||||
maxObjectDepth,
|
||||
depth + 1,
|
||||
visitedObjects,
|
||||
),
|
||||
});
|
||||
}
|
||||
return { type: "map", value: entries };
|
||||
}
|
||||
if (value instanceof Set) {
|
||||
let items = [];
|
||||
for (let v of value.values())
|
||||
items.push(
|
||||
this.serializeBidiRemoteValue(
|
||||
v,
|
||||
maxObjectDepth,
|
||||
depth + 1,
|
||||
visitedObjects,
|
||||
),
|
||||
);
|
||||
return { type: "set", value: items };
|
||||
}
|
||||
if (value instanceof WeakMap) return { type: "weakmap" };
|
||||
if (value instanceof WeakSet) return { type: "weakset" };
|
||||
if (value instanceof ArrayBuffer) return { type: "arraybuffer" };
|
||||
if (ArrayBuffer.isView(value)) return { type: "typedarray" };
|
||||
if (visitedObjects.has(value)) return { type: "object", value: {} };
|
||||
if (depth >= maxObjectDepth) return { type: "object", value: {} };
|
||||
visitedObjects.add(value);
|
||||
try {
|
||||
if (Array.isArray(value)) {
|
||||
let serializedArray = [];
|
||||
for (let i = 0; i < value.length; i++) {
|
||||
serializedArray[i] = this.serializeBidiRemoteValue(
|
||||
value[i],
|
||||
maxObjectDepth,
|
||||
depth + 1,
|
||||
visitedObjects,
|
||||
);
|
||||
}
|
||||
return { type: "array", value: serializedArray };
|
||||
} else {
|
||||
let serializedObject = {};
|
||||
let keys = Object.keys(value).sort();
|
||||
for (let i = 0; i < keys.length; ++i) {
|
||||
let key = keys[i];
|
||||
serializedObject[key] = this.serializeBidiRemoteValue(
|
||||
value[key],
|
||||
maxObjectDepth,
|
||||
depth + 1,
|
||||
visitedObjects,
|
||||
);
|
||||
}
|
||||
return { type: "object", value: serializedObject };
|
||||
}
|
||||
} finally {
|
||||
visitedObjects.delete(value);
|
||||
}
|
||||
}
|
||||
return { type: "undefined" };
|
||||
}
|
||||
};
|
||||
return new AutomationSessionProxy();
|
||||
});
|
||||
177
27.0/js/forms/AutoFillBootstrapper.js
Normal file
177
27.0/js/forms/AutoFillBootstrapper.js
Normal file
@@ -0,0 +1,177 @@
|
||||
//# sourceURL=__InjectedScript_AutoFillBootstrapper.js
|
||||
/* Copyright (c) 2026 Apple Inc. All rights reserved. */
|
||||
"use strict";
|
||||
function initAutoFillBootstrapper() {
|
||||
function e(e) {
|
||||
return (
|
||||
e.isContentEditable && "textbox" === e.role && "true" !== e.ariaMultiLine
|
||||
);
|
||||
}
|
||||
function t(t) {
|
||||
if (t instanceof HTMLTextAreaElement) return !0;
|
||||
if (e(t)) return !0;
|
||||
if (!(t instanceof HTMLInputElement)) return !1;
|
||||
const n = {
|
||||
date: !0,
|
||||
"datetime-local": !0,
|
||||
email: !0,
|
||||
isindex: !0,
|
||||
month: !0,
|
||||
number: !0,
|
||||
password: !0,
|
||||
search: !0,
|
||||
tel: !0,
|
||||
telephone: !0,
|
||||
text: !0,
|
||||
time: !0,
|
||||
url: !0,
|
||||
week: !0,
|
||||
};
|
||||
var a = t.type;
|
||||
return !a || a in n;
|
||||
}
|
||||
function n(e) {
|
||||
const n = e.composedPath()[0];
|
||||
return t(n) ? n : null;
|
||||
}
|
||||
function a(e) {
|
||||
const n = e.composedPath()[0];
|
||||
return !t(n) || n instanceof HTMLTextAreaElement ? null : n;
|
||||
}
|
||||
class i {
|
||||
#e = [];
|
||||
#t = null;
|
||||
#n(e) {
|
||||
switch (e.type) {
|
||||
case "webkitsubmit":
|
||||
return e.target;
|
||||
case "webkitautofillrequest":
|
||||
case "webkitbeforefocus":
|
||||
case "webkitbeforeblur":
|
||||
case "keydown":
|
||||
return a(e);
|
||||
case "webkitusertextinput":
|
||||
return n(e);
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
processAndEnqueue(e, t = !0) {
|
||||
const n = this.#n(e);
|
||||
if (!n) return;
|
||||
let a = null;
|
||||
"keydown" === e.type && (a = { key: e.key, shiftKey: e.shiftKey });
|
||||
const i = { target: n, type: e.type, data: a };
|
||||
this.#t
|
||||
? this.#t.dispatchEvent(i)
|
||||
: (this.#e.push(i), t && o.scheduleIfNeeded());
|
||||
}
|
||||
setDelegate(e) {
|
||||
this.#t = e;
|
||||
for (const e of this.#e) this.#t.dispatchEvent(e);
|
||||
this.#e.length = 0;
|
||||
}
|
||||
}
|
||||
globalThis.eventQueue = new i();
|
||||
class s {
|
||||
#a = null;
|
||||
#i = !1;
|
||||
scheduleIfNeeded() {
|
||||
this.#i ||
|
||||
this.#a ||
|
||||
("complete" === document.readyState
|
||||
? this.requestImmediately()
|
||||
: (this.#a = setTimeout(this.requestImmediately.bind(this), 100)));
|
||||
}
|
||||
requestImmediately() {
|
||||
if (this.#i) return;
|
||||
if (((this.#i = !0), (this.#a = null), !window.webkit.evaluateScript))
|
||||
return void window.webkit.messageHandlers.controller.postMessage({
|
||||
name: "loadMainScriptRequest",
|
||||
});
|
||||
const e = {
|
||||
"safari://FormMetadataContactsAutoFillMappings.js":
|
||||
window.webkit.buffers.FormMetadataContactsAutoFillMappings,
|
||||
"safari://passwordRulesParserJS.js":
|
||||
window.webkit.buffers.PasswordRulesParserJS,
|
||||
"safari://PatternRegexpToPasswordRulesConverter.js":
|
||||
window.webkit.buffers.PatternRegexpToPasswordRulesConverter,
|
||||
"safari://FormMetadataClassification.js":
|
||||
window.webkit.buffers.FormMetadataClassification,
|
||||
"safari://FormMetadata.js": window.webkit.buffers.FormMetadata,
|
||||
"safari://FormMetadataJSController.js":
|
||||
window.webkit.buffers.FormMetadataJSController,
|
||||
"safari://FormMetadataUtilities.js":
|
||||
window.webkit.buffers.FormMetadataUtilities,
|
||||
"safari://AutomaticPasswords.js":
|
||||
window.webkit.buffers.AutomaticPasswords,
|
||||
};
|
||||
window.webkit.buffers.NodePath &&
|
||||
(e["safari://NodePath.js"] = window.webkit.buffers.NodePath);
|
||||
for (const t in e) {
|
||||
let n = e[t].asLatin1String();
|
||||
(AutoFillControllerConfig.isEngineeringBuild &&
|
||||
(n = new TextDecoder("utf8").decode(
|
||||
new Uint8Array([...n].map((e) => e.codePointAt(0))),
|
||||
)),
|
||||
window.webkit.evaluateScript(n, t));
|
||||
}
|
||||
}
|
||||
}
|
||||
const o = new s();
|
||||
((globalThis.evaluateMainScripts = function () {
|
||||
o.requestImmediately();
|
||||
}),
|
||||
(globalThis.addGlobalEventHandler = function (e, t, n = !1, a = !1) {
|
||||
const i = [];
|
||||
(n &&
|
||||
i.push(function (t) {
|
||||
return function (n) {
|
||||
const i = n;
|
||||
window.addEventListener(
|
||||
e,
|
||||
function (e) {
|
||||
e === i && (e.defaultPrevented || t(e));
|
||||
},
|
||||
{ once: !0, capture: !1, webkitTrustedOnly: a },
|
||||
);
|
||||
};
|
||||
}),
|
||||
e.startsWith("webkit") &&
|
||||
i.push(function (e) {
|
||||
return function (t) {
|
||||
(t.stopImmediatePropagation(), e(t));
|
||||
};
|
||||
}));
|
||||
let s = t;
|
||||
for (const e of i) s = e(s);
|
||||
window.addEventListener(e, s, { capture: !0, webkitTrustedOnly: a });
|
||||
}),
|
||||
(globalThis.addEventListeners = function () {
|
||||
(addGlobalEventHandler("webkitbeforefocus", (e) =>
|
||||
eventQueue.processAndEnqueue(e, AutoFillControllerConfig.isMac),
|
||||
),
|
||||
addGlobalEventHandler("webkitbeforeblur", (e) =>
|
||||
eventQueue.processAndEnqueue(e),
|
||||
),
|
||||
addGlobalEventHandler("webkitusertextinput", (e) =>
|
||||
eventQueue.processAndEnqueue(e),
|
||||
),
|
||||
addGlobalEventHandler(
|
||||
"keydown",
|
||||
(e) => eventQueue.processAndEnqueue(e),
|
||||
!0,
|
||||
!0,
|
||||
),
|
||||
addGlobalEventHandler("webkitsubmit", (e) =>
|
||||
eventQueue.processAndEnqueue(e),
|
||||
),
|
||||
addGlobalEventHandler("webkitautofillrequest", (e) =>
|
||||
eventQueue.processAndEnqueue(e),
|
||||
));
|
||||
}));
|
||||
}
|
||||
(void 0 === globalThis.autoFillBootstrapperInited &&
|
||||
(initAutoFillBootstrapper(), (globalThis.autoFillBootstrapperInited = !0)),
|
||||
globalThis.addEventListeners());
|
||||
0;
|
||||
31
27.0/js/forms/AutomaticPasswords.js
Normal file
31
27.0/js/forms/AutomaticPasswords.js
Normal file
@@ -0,0 +1,31 @@
|
||||
//# sourceURL=__InjectedScript_AutomaticPasswords.js
|
||||
/* Copyright (c) 2026 Apple Inc. All rights reserved. */
|
||||
"use strict";
|
||||
class AutomaticPasswords {
|
||||
removeAutomaticPasswordElements(t, e, o) {
|
||||
for (let e of t)
|
||||
FormMetadataJS.removeAutomaticStrongPasswordFromPasswordElement(e);
|
||||
if (!o) return;
|
||||
let r = document.activeElement,
|
||||
a = e ? FormMetadataJS.formControlWithUniqueID(e) : null;
|
||||
(a && a.blur(), a && a === r && a.focus());
|
||||
}
|
||||
blurControlWithID(t) {
|
||||
let e = t ? FormMetadataJS.formControlWithUniqueID(t) : null;
|
||||
e && e.blur();
|
||||
}
|
||||
setStrongPasswordElementViewableIfAppropriate(t, e) {
|
||||
for (let o of t) {
|
||||
let t = FormMetadataJS.formControlWithUniqueID(o);
|
||||
if (!t) return;
|
||||
if ("text" === t.type)
|
||||
return (
|
||||
FormMetadataJSController.setInputElementAutoFilledAndViewable(t, !1),
|
||||
void FormMetadataJSController.setInputElementAutofilled(t, !1)
|
||||
);
|
||||
FormMetadataJSController.setInputElementAutoFilledAndViewable(t, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
var AutomaticPasswordsJS = new AutomaticPasswords();
|
||||
0;
|
||||
5570
27.0/js/forms/FormMetadata.js
Normal file
5570
27.0/js/forms/FormMetadata.js
Normal file
File diff suppressed because it is too large
Load Diff
923
27.0/js/forms/FormMetadataClassification.js
Normal file
923
27.0/js/forms/FormMetadataClassification.js
Normal file
@@ -0,0 +1,923 @@
|
||||
//# sourceURL=__InjectedScript_FormMetadataClassification.js
|
||||
/* Copyright (c) 2026 Apple Inc. All rights reserved. */
|
||||
"use strict";
|
||||
function datePlaceholderParser(e) {
|
||||
const t = [];
|
||||
for (const o of e)
|
||||
"d" !== o || t.includes("day")
|
||||
? "M" !== o || t.includes("month")
|
||||
? "y" !== o || t.includes("year") || t.push("year")
|
||||
: t.push("month")
|
||||
: t.push("day");
|
||||
return e.includes("d")
|
||||
? e.includes("yyyy")
|
||||
? {
|
||||
format: { year: "numeric", month: "2-digit", day: "2-digit" },
|
||||
order: t,
|
||||
}
|
||||
: {
|
||||
format: { year: "2-digit", month: "2-digit", day: "2-digit" },
|
||||
order: t,
|
||||
}
|
||||
: e.includes("M")
|
||||
? e.includes("yyyy")
|
||||
? { format: { year: "numeric", month: "2-digit" }, order: t }
|
||||
: { format: { year: "2-digit", month: "2-digit" }, order: t }
|
||||
: e.includes("y")
|
||||
? e.includes("yyyy")
|
||||
? { format: { year: "numeric" }, order: t }
|
||||
: { format: { year: "2-digit" }, order: t }
|
||||
: null;
|
||||
}
|
||||
function referenceDateToDateFormat(e) {
|
||||
let t = e.replace("12", "MM");
|
||||
return (
|
||||
(t = t.replace("30", "dd")),
|
||||
(t = t.replace("1999", "y")),
|
||||
(t = t.replace("99", "yy")),
|
||||
t
|
||||
);
|
||||
}
|
||||
function referenceDatePartsToOrderedDateFormat(e, t) {
|
||||
const o = {};
|
||||
let r = "";
|
||||
for (const t of e)
|
||||
switch (t.type) {
|
||||
case "day":
|
||||
o.day = "dd";
|
||||
break;
|
||||
case "month":
|
||||
o.month = "MM";
|
||||
break;
|
||||
case "year":
|
||||
o.year = "1999" === t.value ? "yyyy" : "yy";
|
||||
break;
|
||||
case "literal":
|
||||
r = t.value;
|
||||
}
|
||||
let n = "";
|
||||
for (const [e, i] of t.entries())
|
||||
(o[i] && (n += o[i]), e < t.length - 1 && r && (n += r));
|
||||
return n;
|
||||
}
|
||||
const WBSABAddressProperty = "Address",
|
||||
WBSABPhoneProperty = "Phone",
|
||||
_WBSABAddressZIPKey = "ZIP",
|
||||
WBSFormControlMetadataDefaultMaxLength = 524288,
|
||||
WBSIgnoredClassificationToken = "-sf-ignored",
|
||||
WBSDateDayOrderedPartToken = "-sf-day",
|
||||
WBSDateMonthOrderedPartToken = "-sf-month",
|
||||
WBSDateYearOrderedPartToken = "-sf-year",
|
||||
WBSGivenNameOrderedPartToken = "given-name",
|
||||
WBSAdditionalNameOrderedPartToken = "additional-name",
|
||||
WBSFamilyNameOrderedPartToken = "family-name",
|
||||
WBSLocaleForCreditCardExpirationDate = "en-US-POSIX",
|
||||
WBSCreditCardTypeClassificationToken = "cc-type",
|
||||
WBSCreditCardHolderNameClassificationToken = "cc-name",
|
||||
WBSCreditCardNumberClassificationToken = "cc-number",
|
||||
WBSCreditCardExpirationClassificationToken = "cc-exp",
|
||||
WBSCreditCardSecurityCodeClassificationToken = "cc-csc",
|
||||
WBSCreditCardHolderNameClassificationDefaultOrderedParts = [
|
||||
WBSGivenNameOrderedPartToken,
|
||||
WBSAdditionalNameOrderedPartToken,
|
||||
WBSFamilyNameOrderedPartToken,
|
||||
],
|
||||
WBSCreditCardExpirationClassificationDefaultOrderedParts = [
|
||||
WBSDateMonthOrderedPartToken,
|
||||
WBSDateYearOrderedPartToken,
|
||||
],
|
||||
WBSCredentialUsernameClassificationToken = "username",
|
||||
WBSCredentialCurrentPasswordClassificationToken = "current-password",
|
||||
WBSCredentialNewPasswordClassificationToken = "new-password",
|
||||
WBSContactNameClassificationToken = "name",
|
||||
WBSContactNameClassificationDefaultOrderedParts = [
|
||||
WBSGivenNameOrderedPartToken,
|
||||
WBSAdditionalNameOrderedPartToken,
|
||||
WBSFamilyNameOrderedPartToken,
|
||||
],
|
||||
WBSNameOrderedPartTokensSet = new Set(
|
||||
WBSContactNameClassificationDefaultOrderedParts,
|
||||
),
|
||||
WBSContactInstantMessageClassificationToken = "-sf-instant-message",
|
||||
WBSContactPostalCodeClassificationToken = "postal-code",
|
||||
WBSContactStreetAddressClassificationToken = "street-address",
|
||||
WBSContactStreetAddressLine1OrderedPartToken = "address-line1",
|
||||
WBSContactStreetAddressLine2OrderedPartToken = "address-line2",
|
||||
WBSContactStreetAddressLine3OrderedPartToken = "address-line3",
|
||||
WBSContactTelephoneClassificationToken = "tel",
|
||||
WBSTelephoneCountryCodeOrderedPartToken = "tel-country-code",
|
||||
WBSTelephoneAreaCodeOrderedPartToken = "tel-area-code",
|
||||
WBSTelephoneLocalPrefixOrderedPartToken = "tel-local-prefix",
|
||||
WBSTelephoneLocalSuffixOrderedPartToken = "tel-local-suffix",
|
||||
WBSTelephoneExtensionOrderedPartToken = "tel-extension",
|
||||
WBSTelephoneDefaultOrderedParts = [
|
||||
WBSTelephoneCountryCodeOrderedPartToken,
|
||||
WBSTelephoneAreaCodeOrderedPartToken,
|
||||
WBSTelephoneLocalPrefixOrderedPartToken,
|
||||
WBSTelephoneLocalSuffixOrderedPartToken,
|
||||
WBSTelephoneExtensionOrderedPartToken,
|
||||
],
|
||||
WBSContactBirthdayClassificationToken = "bday",
|
||||
WBSContactEmailClassificationToken = "email",
|
||||
WBSDeviceEIDClassificationToken = "device-eid",
|
||||
WBSDeviceIMEIClassificationToken = "device-imei",
|
||||
WBSDeviceIMEI1ClassificationToken = "device-imei1",
|
||||
WBSDeviceIMEI2ClassificationToken = "device-imei2",
|
||||
WBSDeviceNALClassificationToken = "device-nal",
|
||||
AllowedControlTagsForStandaloneCreditCardCompositeExpirationControl = new Set(
|
||||
["input", "select", "textarea"],
|
||||
);
|
||||
class JSFieldLabelPatternMatcher {
|
||||
constructor(e, t) {
|
||||
((this.dfa = e),
|
||||
(this.characters = t.toLowerCase()),
|
||||
(this.allowEndOfWordMatch = e.charCodeAt(1)));
|
||||
const o = e.charCodeAt(0),
|
||||
r = 2,
|
||||
n = 2;
|
||||
this.transitionsBegin = r + n * o;
|
||||
}
|
||||
static transitionsEndMatchSentinel = 0;
|
||||
longestMatch() {
|
||||
let e,
|
||||
t = 0;
|
||||
const o = this.characters.length;
|
||||
let r = this.search(t, o, o);
|
||||
for (; r.length;) {
|
||||
for (const o of r)
|
||||
((!e || o.end - o.begin > e.end - e.begin) && (e = o),
|
||||
(t = o.begin + 1));
|
||||
r = this.search(t, o, o);
|
||||
}
|
||||
if (e) return [e.identifier, this.characters.substring(e.begin, e.end)];
|
||||
}
|
||||
searchReverse() {
|
||||
let e = 0;
|
||||
const t = this.characters.length;
|
||||
let o,
|
||||
r = this.search(e, t, t);
|
||||
for (; r.length;) {
|
||||
for (const t of r) ((!o || t.end > o.end) && (o = t), (e = t.begin + 1));
|
||||
r = this.search(e, t, t);
|
||||
}
|
||||
if (o) return [o.identifier, this.characters.substring(o.begin, o.end)];
|
||||
}
|
||||
exactMatch() {
|
||||
const e = this.characters.length,
|
||||
t = this.search(0, e, 1);
|
||||
for (const o of t) if (0 == o.begin && o.end == e) return o.identifier;
|
||||
}
|
||||
static isWordCharacter(e) {
|
||||
return (
|
||||
(e >= 97 && e <= 122) ||
|
||||
(e >= 65 && e <= 90) ||
|
||||
(e >= 48 && e <= 57) ||
|
||||
95 == e
|
||||
);
|
||||
}
|
||||
isWordBoundary(e) {
|
||||
return (
|
||||
!!this.characters.length &&
|
||||
(0 === e
|
||||
? JSFieldLabelPatternMatcher.isWordCharacter(
|
||||
this.characters.charCodeAt(0),
|
||||
)
|
||||
: e === this.characters.length
|
||||
? JSFieldLabelPatternMatcher.isWordCharacter(
|
||||
this.characters.charCodeAt(e - 1),
|
||||
)
|
||||
: JSFieldLabelPatternMatcher.isWordCharacter(
|
||||
this.characters.charCodeAt(e - 1),
|
||||
) !=
|
||||
JSFieldLabelPatternMatcher.isWordCharacter(
|
||||
this.characters.charCodeAt(e),
|
||||
))
|
||||
);
|
||||
}
|
||||
passesWordBoundaryCheck(e, t) {
|
||||
return (
|
||||
!(
|
||||
!this.allowEndOfWordMatch &&
|
||||
JSFieldLabelPatternMatcher.isWordCharacter(
|
||||
this.characters.charCodeAt(e),
|
||||
) &&
|
||||
!this.isWordBoundary(e)
|
||||
) &&
|
||||
(!JSFieldLabelPatternMatcher.isWordCharacter(
|
||||
this.characters.charCodeAt(t),
|
||||
) ||
|
||||
this.isWordBoundary(t + 1))
|
||||
);
|
||||
}
|
||||
search(e, t, o) {
|
||||
let r = [];
|
||||
for (var n = e; n < o; n++) {
|
||||
let e = 0;
|
||||
for (
|
||||
var i = this.stateTransitionBegin(e),
|
||||
a = this.stateTransitionEnd(e),
|
||||
s = n;
|
||||
s < t;
|
||||
s++
|
||||
) {
|
||||
((i = this.stateTransitionBegin(e)), (a = this.stateTransitionEnd(e)));
|
||||
const t = this.characters.charCodeAt(s);
|
||||
let o = !1;
|
||||
for (var d = i, l = a - 1; d <= l;) {
|
||||
const r = ((d + l) / 2) | 0,
|
||||
n = this.transitionCharacter(r);
|
||||
if (n == t) {
|
||||
((e = this.transitionStateIndex(r)),
|
||||
(i = this.stateTransitionBegin(e)),
|
||||
(a = this.stateTransitionEnd(e)),
|
||||
(o = !0));
|
||||
break;
|
||||
}
|
||||
n > t ? (l = r - 1) : (d = r + 1);
|
||||
}
|
||||
if (!o) break;
|
||||
for (; a == JSFieldLabelPatternMatcher.transitionsEndMatchSentinel;)
|
||||
(this.passesWordBoundaryCheck(n, s) &&
|
||||
r.push({ identifier: i, begin: n, end: s + 1 }),
|
||||
e++,
|
||||
(i = this.stateTransitionBegin(e)),
|
||||
(a = this.stateTransitionEnd(e)));
|
||||
}
|
||||
}
|
||||
return r;
|
||||
}
|
||||
stateTransitionBegin(e) {
|
||||
const t = 2,
|
||||
o = 2;
|
||||
return this.dfa.charCodeAt(t + o * e);
|
||||
}
|
||||
stateTransitionEnd(e) {
|
||||
const t = 2,
|
||||
o = 2;
|
||||
return this.dfa.charCodeAt(t + o * e + 1);
|
||||
}
|
||||
transitionCharacter(e) {
|
||||
const t = 2;
|
||||
return this.dfa.charCodeAt(this.transitionsBegin + t * e);
|
||||
}
|
||||
transitionStateIndex(e) {
|
||||
const t = 2;
|
||||
return this.dfa.charCodeAt(this.transitionsBegin + t * e + 1);
|
||||
}
|
||||
}
|
||||
class FormMetadataClassification {
|
||||
#e(e) {
|
||||
return null != e && "object" == typeof e;
|
||||
}
|
||||
#t(e) {
|
||||
return this.#e(e) && "string" == typeof e.ControlTagName;
|
||||
}
|
||||
#o(e) {
|
||||
return this.#e(e) && "string" == typeof e.property;
|
||||
}
|
||||
fieldLooksLikeDateField(e) {
|
||||
return !!(
|
||||
e.ControlLooksLikeDayField ||
|
||||
e.ControlLooksLikeMonthField ||
|
||||
e.ControlLooksLikeYearField
|
||||
);
|
||||
}
|
||||
#r(e) {
|
||||
let t = e.ControlMaxLength;
|
||||
return (
|
||||
(void 0 === t || t < 0 || t > WBSFormControlMetadataDefaultMaxLength) &&
|
||||
(t = WBSFormControlMetadataDefaultMaxLength),
|
||||
t
|
||||
);
|
||||
}
|
||||
fieldLooksLikeItExpectsDataOfSize(e, t) {
|
||||
return (e.ControlSize ?? 0) <= t || this.#r(e) <= t;
|
||||
}
|
||||
fieldCouldBeCreditCardNumberContinuation(e, t) {
|
||||
const o = 4;
|
||||
if (t.length >= o) return !1;
|
||||
if (!t[0]?.ControlLooksLikeCreditCardNumberField) return !1;
|
||||
const r = 2;
|
||||
if (e.ControlMaxLength === r) return !1;
|
||||
if (e.ControlLooksLikeCreditCardNumberField) return !0;
|
||||
if (e.ControlLooksLikeCreditCardSecurityCodeField) return !1;
|
||||
if (e.ControlLooksLikeCreditCardCompositeExpirationDateField) return !1;
|
||||
const n = 6;
|
||||
if (!this.fieldLooksLikeItExpectsDataOfSize(e, n)) return !1;
|
||||
const i = t.at(-1);
|
||||
return !(i && !this.fieldLooksLikeItExpectsDataOfSize(i, n));
|
||||
}
|
||||
labelsCouldRepresentContinuation(e, t, o, r) {
|
||||
return (
|
||||
!(!e || !o) &&
|
||||
(e === o ||
|
||||
(!!t &&
|
||||
(!r ||
|
||||
(t.property === r.property &&
|
||||
(!r.component || t.component === r.component)))))
|
||||
);
|
||||
}
|
||||
#n(e) {
|
||||
const t = [
|
||||
WBSContactStreetAddressLine1OrderedPartToken,
|
||||
WBSContactStreetAddressLine2OrderedPartToken,
|
||||
WBSContactStreetAddressLine3OrderedPartToken,
|
||||
],
|
||||
o = [
|
||||
WBSContactStreetAddressLine2OrderedPartToken,
|
||||
WBSContactStreetAddressLine3OrderedPartToken,
|
||||
];
|
||||
if (e.AutocompleteTokens)
|
||||
for (let o of e.AutocompleteTokens)
|
||||
switch (o) {
|
||||
case "street-address":
|
||||
return t;
|
||||
case "address-line1":
|
||||
return [WBSContactStreetAddressLine1OrderedPartToken];
|
||||
case "address-line2":
|
||||
case "address-level2":
|
||||
return [WBSContactStreetAddressLine2OrderedPartToken];
|
||||
case "address-line3":
|
||||
case "address-level1":
|
||||
return [WBSContactStreetAddressLine3OrderedPartToken];
|
||||
}
|
||||
let r = e.ControlFieldName,
|
||||
n = r?.indexOf("1") ?? -1,
|
||||
i = r?.indexOf("2") ?? -1;
|
||||
return -1 === n
|
||||
? -1 === i
|
||||
? t
|
||||
: o
|
||||
: -1 === i || n < i
|
||||
? [WBSContactStreetAddressLine1OrderedPartToken]
|
||||
: o;
|
||||
}
|
||||
fieldCouldBePhoneNumberContinuation(e, t) {
|
||||
const o = 5;
|
||||
if (t.length >= o) return !1;
|
||||
if (t[0]?.AddressBookValueSpecifier?.property !== WBSABPhoneProperty)
|
||||
return !1;
|
||||
const r = 5;
|
||||
return !!this.fieldLooksLikeItExpectsDataOfSize(e, r);
|
||||
}
|
||||
fieldCouldBePostCodeContinuation(e, t) {
|
||||
const o = 3;
|
||||
if (t.length >= o) return !1;
|
||||
if (t[0]?.AddressBookValueSpecifier?.component != _WBSABAddressZIPKey)
|
||||
return !1;
|
||||
const r = 6;
|
||||
return !!this.fieldLooksLikeItExpectsDataOfSize(e, r);
|
||||
}
|
||||
fieldLooksLikeSameDataType(e, t) {
|
||||
const o = t.at(-1);
|
||||
return (
|
||||
!!this.labelsCouldRepresentContinuation(
|
||||
o?.AddressBookLabel,
|
||||
o?.AddressBookValueSpecifier,
|
||||
e?.AddressBookLabel,
|
||||
e?.AddressBookValueSpecifier,
|
||||
) ||
|
||||
!!(
|
||||
o &&
|
||||
this.fieldLooksLikeDateField(o) &&
|
||||
this.fieldLooksLikeDateField(e)
|
||||
) ||
|
||||
!!this.fieldCouldBePhoneNumberContinuation(e, t) ||
|
||||
!!this.fieldCouldBePostCodeContinuation(e, t) ||
|
||||
!!this.fieldCouldBeCreditCardNumberContinuation(e, t)
|
||||
);
|
||||
}
|
||||
#i(e) {
|
||||
if (
|
||||
(globalThis.DOMRect ||
|
||||
(globalThis.DOMRect = class {
|
||||
constructor(e, t, o, r) {
|
||||
((this.left = e),
|
||||
(this.right = e + o),
|
||||
(this.top = t),
|
||||
(this.bottom = t + r),
|
||||
(this.width = o),
|
||||
(this.height = r));
|
||||
}
|
||||
}),
|
||||
e.ControlRectLeft ||
|
||||
e.ControlRectTop ||
|
||||
e.ControlRectWidth ||
|
||||
e.ControlRectHeight)
|
||||
)
|
||||
return new DOMRect(
|
||||
e.ControlRectLeft,
|
||||
e.ControlRectTop,
|
||||
e.ControlRectWidth,
|
||||
e.ControlRectHeight,
|
||||
);
|
||||
let t = globalThis.FormMetadataJS?.formControlWithUniqueID(
|
||||
e.ControlUniqueID,
|
||||
);
|
||||
return t ? t.getBoundingClientRect() : new DOMRect(0, 0, 0, 0);
|
||||
}
|
||||
fieldLooksLikeContinuation(e, t, o) {
|
||||
if (!e.ControlIsTextField && "SELECT" !== e.ControlTagName.toUpperCase())
|
||||
return !1;
|
||||
if (!this.fieldLooksLikeSameDataType(e, t)) return !1;
|
||||
if (o) return !0;
|
||||
const r = this.#i(t.at(-1)),
|
||||
n = this.#i(e);
|
||||
if (Math.abs(r.top - n.top) > 3) return !1;
|
||||
let i, a;
|
||||
return (
|
||||
r.left < n.left ? ((i = r), (a = n)) : ((i = n), (a = r)),
|
||||
!(a.left - i.right > 60)
|
||||
);
|
||||
}
|
||||
continuingFieldsInFormControls(e, t, o, r) {
|
||||
const n = [e[t]];
|
||||
for (let i = t + 1; i < e.length; ++i) {
|
||||
const t = e[i];
|
||||
if (o && !t.ControlIsTextField) break;
|
||||
if (!this.fieldLooksLikeContinuation(t, n, r)) break;
|
||||
n.push(t);
|
||||
}
|
||||
return n;
|
||||
}
|
||||
classifyControlsRelatedToNameParts(e, t, o) {
|
||||
const r = e[t];
|
||||
((r.ControlClassification = o),
|
||||
(r.ControlOrderedParts = [r.AddressBookValueSpecifier?.classification]));
|
||||
const n = new Set([r.AddressBookValueSpecifier?.classification]),
|
||||
i = [e[t]];
|
||||
for (let r = t + 1; r < e.length; ++r) {
|
||||
const t = e[r];
|
||||
if (!t.ControlIsTextField) break;
|
||||
const a = t.AddressBookValueSpecifier?.classification;
|
||||
if (!a) break;
|
||||
if (!WBSNameOrderedPartTokensSet.has(a) || n.has(a)) break;
|
||||
((t.ControlClassification = o),
|
||||
(t.ControlOrderedParts = [a]),
|
||||
n.add(a),
|
||||
i.push(t));
|
||||
}
|
||||
return i;
|
||||
}
|
||||
identifyDateFields(e) {
|
||||
let t,
|
||||
o,
|
||||
r,
|
||||
n = !1;
|
||||
for (let i of e)
|
||||
if (i.ControlLooksLikeDayField) {
|
||||
if (t) return [!1, null, null, null];
|
||||
((t = i), (n = !0));
|
||||
} else if (i.ControlLooksLikeMonthField) {
|
||||
if (o) return [!1, null, null, null];
|
||||
((o = i), (n = !0));
|
||||
} else if (i.ControlLooksLikeYearField) {
|
||||
if (r) return [!1, null, null, null];
|
||||
((r = i), (n = !0));
|
||||
}
|
||||
return [n, r, o, t];
|
||||
}
|
||||
canonicalizedDateTemplate(e) {
|
||||
if (!e) return;
|
||||
if (!(e = e.replace(/\s/g, "")).length) return;
|
||||
const t = [
|
||||
{
|
||||
dateFormatCharactersRegex: /^[dmy\/.-]*$/i,
|
||||
dayRegex: /D/g,
|
||||
monthRegex: /m/g,
|
||||
yearRegex: /Y/g,
|
||||
},
|
||||
{
|
||||
dateFormatCharactersRegex: /^[jma\/.-]*$/i,
|
||||
dayRegex: /j/gi,
|
||||
monthRegex: /m/g,
|
||||
yearRegex: /a/gi,
|
||||
},
|
||||
{
|
||||
dateFormatCharactersRegex: /^[dma\/.-]*$/i,
|
||||
dayRegex: /D/g,
|
||||
monthRegex: /m/g,
|
||||
yearRegex: /a/gi,
|
||||
},
|
||||
{
|
||||
dateFormatCharactersRegex: /^[tmj\/.-]*$/i,
|
||||
dayRegex: /t/gi,
|
||||
monthRegex: /m/g,
|
||||
yearRegex: /j/gi,
|
||||
},
|
||||
{
|
||||
dateFormatCharactersRegex: /^[gma\/.-]*$/i,
|
||||
dayRegex: /g/gi,
|
||||
monthRegex: /m/g,
|
||||
yearRegex: /a/gi,
|
||||
},
|
||||
];
|
||||
for (const {
|
||||
dateFormatCharactersRegex: o,
|
||||
dayRegex: r,
|
||||
monthRegex: n,
|
||||
yearRegex: i,
|
||||
} of t)
|
||||
if (o.test(e))
|
||||
return (e = (e = (e = e.replace(r, "d")).replace(n, "M")).replace(
|
||||
i,
|
||||
"y",
|
||||
));
|
||||
}
|
||||
classifyDateFields(e, t, o, r, n, i, a) {
|
||||
if (e.length > 3) return !1;
|
||||
if ((a || (a = navigator.language), 1 === e.length)) {
|
||||
if (!e[0].ControlIsTextField) return !1;
|
||||
let i = e[0].ControlRequiredFormatForDateTimeInput;
|
||||
if (!i) {
|
||||
const t = new Date(1999, 11, 30);
|
||||
let o = this.#r(e[0]),
|
||||
r = this.canonicalizedDateTemplate(e[0].ControlPlaceholder),
|
||||
s = "";
|
||||
if (r?.length) {
|
||||
const e = datePlaceholderParser(r);
|
||||
if (e) {
|
||||
const o = new Intl.DateTimeFormat(a, e.format);
|
||||
s = o.format(t);
|
||||
i = referenceDatePartsToOrderedDateFormat(
|
||||
o.formatToParts(t),
|
||||
e.order,
|
||||
);
|
||||
}
|
||||
}
|
||||
if (!s || s.length > o) {
|
||||
const e = n
|
||||
? [
|
||||
{ year: "numeric", month: "2-digit", day: "2-digit" },
|
||||
{ year: "2-digit", month: "2-digit", day: "2-digit" },
|
||||
]
|
||||
: [{ year: "2-digit", month: "2-digit" }];
|
||||
for (const r of e)
|
||||
if (
|
||||
((s = new Intl.DateTimeFormat(a, r).format(t)),
|
||||
(i = referenceDateToDateFormat(s)),
|
||||
s.length <= o)
|
||||
)
|
||||
break;
|
||||
}
|
||||
if (s.length > o) return !1;
|
||||
}
|
||||
const s = [];
|
||||
for (const e of i) {
|
||||
let t;
|
||||
("y" === e ? (t = o) : "M" === e ? (t = r) : "d" === e && (t = n),
|
||||
t && !s.includes(t) && s.push(t));
|
||||
}
|
||||
return (
|
||||
(e[0].ControlClassification = t),
|
||||
(e[0].ControlOrderedParts = s),
|
||||
(e[0].ControlRequiredFormatForDateTimeInput = i),
|
||||
!0
|
||||
);
|
||||
}
|
||||
let [s, d, l, c] = this.identifyDateFields(e);
|
||||
if (!s) return !1;
|
||||
if (c && !l) return !1;
|
||||
let C = 0;
|
||||
for (const a of e)
|
||||
((a.ControlClassification = t),
|
||||
(a.ControlContinuationID = i),
|
||||
(a.ControlContinuationIndex = C++),
|
||||
a === c
|
||||
? (a.ControlOrderedParts = [n])
|
||||
: a === l
|
||||
? (a.ControlOrderedParts = [r])
|
||||
: a === d && (a.ControlOrderedParts = [o]));
|
||||
return !0;
|
||||
}
|
||||
static specifierForAutocompleteTokensAndAddressBookLabel(e, t) {
|
||||
if (e) {
|
||||
if (!Array.isArray(e))
|
||||
throw new Error("Expected an array of autocomplete tokens");
|
||||
for (let t of e) {
|
||||
const e = new JSFieldLabelPatternMatcher(
|
||||
FormMetadataJSController.autocompleteTokenMapDFA(),
|
||||
t,
|
||||
).exactMatch();
|
||||
if (void 0 !== e) return FormMetadataJSController.getValueSpecifiers(e);
|
||||
}
|
||||
}
|
||||
if (t) {
|
||||
const e = new JSFieldLabelPatternMatcher(
|
||||
FormMetadataJSController.fieldLabelMapDFA(),
|
||||
t,
|
||||
).exactMatch();
|
||||
if (void 0 !== e) return FormMetadataJSController.getValueSpecifiers(e);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
classify(e) {
|
||||
const t = e.FormControls,
|
||||
o = t.length,
|
||||
r = e.AutoFillFormType === WBSAutoFillFormTypeNewAccount,
|
||||
n = e.AutoFillFormType === WBSAutoFillFormTypeChangePassword,
|
||||
i = e.UsernameElementUniqueID,
|
||||
a = e.PasswordElementUniqueID,
|
||||
s = e.OldPasswordElementUniqueID,
|
||||
d = e.ConfirmPasswordElementUniqueID;
|
||||
for (let e of t)
|
||||
(e.AutocompleteTokens || e.AddressBookLabel) &&
|
||||
(e.AddressBookValueSpecifier =
|
||||
FormMetadataClassification.specifierForAutocompleteTokensAndAddressBookLabel(
|
||||
e.AutocompleteTokens,
|
||||
e.AddressBookLabel,
|
||||
));
|
||||
let l = !1,
|
||||
c = !1,
|
||||
C = !1,
|
||||
f = !1,
|
||||
h = !1,
|
||||
u = 0;
|
||||
for (let k = 0, S = 1; k < o; k += S, S = 1) {
|
||||
const o = t[k];
|
||||
if (o.ControlLooksLikeIgnoredDataTypeField) {
|
||||
o.ControlClassification = WBSIgnoredClassificationToken;
|
||||
continue;
|
||||
}
|
||||
const T = o.ControlUniqueID;
|
||||
if (T === a || T === d) {
|
||||
o.ControlClassification =
|
||||
r || n
|
||||
? WBSCredentialNewPasswordClassificationToken
|
||||
: WBSCredentialCurrentPasswordClassificationToken;
|
||||
continue;
|
||||
}
|
||||
if (T === s) {
|
||||
o.ControlClassification =
|
||||
WBSCredentialCurrentPasswordClassificationToken;
|
||||
continue;
|
||||
}
|
||||
const B = o.AddressBookValueSpecifier?.classification;
|
||||
if (B === WBSContactEmailClassificationToken) {
|
||||
o.ControlClassification = WBSContactEmailClassificationToken;
|
||||
continue;
|
||||
}
|
||||
if (T === i) {
|
||||
o.ControlClassification = WBSCredentialUsernameClassificationToken;
|
||||
continue;
|
||||
}
|
||||
if (!c && o.ControlLooksLikeCreditCardCardholderField) {
|
||||
if (((c = !0), B && WBSNameOrderedPartTokensSet.has(B))) {
|
||||
const e = this.classifyControlsRelatedToNameParts(
|
||||
t,
|
||||
k,
|
||||
WBSCreditCardHolderNameClassificationToken,
|
||||
);
|
||||
if (e.length > 1) {
|
||||
let t = ++u,
|
||||
o = 0;
|
||||
for (let r of e)
|
||||
((r.ControlContinuationID = t),
|
||||
(r.ControlContinuationIndex = o++));
|
||||
}
|
||||
S = e.length;
|
||||
continue;
|
||||
}
|
||||
((o.ControlClassification = WBSCreditCardHolderNameClassificationToken),
|
||||
(o.ControlOrderedParts =
|
||||
WBSCreditCardHolderNameClassificationDefaultOrderedParts));
|
||||
continue;
|
||||
}
|
||||
if (!l && o.ControlLooksLikeCreditCardNumberField) {
|
||||
l = !0;
|
||||
const e = this.continuingFieldsInFormControls(t, k, !0, !1);
|
||||
let o = 0,
|
||||
r = e.length > 1 ? ++u : 0;
|
||||
for (let t of e)
|
||||
((t.ControlClassification = WBSCreditCardNumberClassificationToken),
|
||||
(t.ControlContinuationID = r),
|
||||
(t.ControlContinuationIndex = o++));
|
||||
S = e.length;
|
||||
continue;
|
||||
}
|
||||
const g =
|
||||
this.fieldLooksLikeDateField(o) ||
|
||||
o.ControlLooksLikeCreditCardCompositeExpirationDateField;
|
||||
if (!C && g) {
|
||||
let e = f || c || l;
|
||||
if (
|
||||
((e ||=
|
||||
!o.ControlLooksLikeOneTimeCodeField &&
|
||||
1 ===
|
||||
t.filter((e) =>
|
||||
AllowedControlTagsForStandaloneCreditCardCompositeExpirationControl.has(
|
||||
e.ControlTagName.toLowerCase(),
|
||||
),
|
||||
).length),
|
||||
e)
|
||||
) {
|
||||
C = !0;
|
||||
const e = this.continuingFieldsInFormControls(t, k, !1, !0);
|
||||
let o = e.length > 1 ? ++u : 0;
|
||||
(this.classifyDateFields(
|
||||
e,
|
||||
WBSCreditCardExpirationClassificationToken,
|
||||
WBSDateYearOrderedPartToken,
|
||||
WBSDateMonthOrderedPartToken,
|
||||
void 0,
|
||||
o,
|
||||
WBSLocaleForCreditCardExpirationDate,
|
||||
),
|
||||
(S = e.length));
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if (h || !o.ControlLooksLikeCreditCardSecurityCodeField)
|
||||
if (f || !o.ControlLooksLikeCreditCardTypeField)
|
||||
if (B) {
|
||||
const r = o.AddressBookValueSpecifier.classificationHint;
|
||||
if (B === WBSContactNameClassificationToken) {
|
||||
((o.ControlClassification = B),
|
||||
(o.ControlOrderedParts =
|
||||
WBSContactNameClassificationDefaultOrderedParts));
|
||||
continue;
|
||||
}
|
||||
if (WBSNameOrderedPartTokensSet.has(B)) {
|
||||
const e = this.classifyControlsRelatedToNameParts(
|
||||
t,
|
||||
k,
|
||||
WBSContactNameClassificationToken,
|
||||
);
|
||||
if (e.length > 1) {
|
||||
let t = ++u,
|
||||
o = 0;
|
||||
for (let r of e)
|
||||
((r.ControlContinuationID = t),
|
||||
(r.ControlContinuationIndex = o++));
|
||||
}
|
||||
S = e.length;
|
||||
continue;
|
||||
}
|
||||
if (B === WBSContactPostalCodeClassificationToken) {
|
||||
const e = this.continuingFieldsInFormControls(t, k, !0, !1);
|
||||
let o = e.length > 1 ? ++u : 0,
|
||||
r = 0;
|
||||
for (let t of e)
|
||||
((t.ControlClassification =
|
||||
WBSContactPostalCodeClassificationToken),
|
||||
(t.ControlContinuationID = o),
|
||||
(t.ControlContinuationIndex = r++));
|
||||
S = e.length;
|
||||
continue;
|
||||
}
|
||||
if (B === WBSContactStreetAddressClassificationToken) {
|
||||
const e = this.continuingFieldsInFormControls(t, k, !0, !0);
|
||||
let o = e.length > 1 ? ++u : 0,
|
||||
r = 0;
|
||||
for (let t of e)
|
||||
((t.ControlClassification =
|
||||
WBSContactStreetAddressClassificationToken),
|
||||
(t.ControlContinuationID = o),
|
||||
(t.ControlContinuationIndex = r++));
|
||||
if (1 === e.length) {
|
||||
let t = e[0];
|
||||
t.ControlOrderedParts = this.#n(t);
|
||||
} else
|
||||
2 === e.length
|
||||
? ((e[0].ControlOrderedParts = [
|
||||
WBSContactStreetAddressLine1OrderedPartToken,
|
||||
]),
|
||||
(e[1].ControlOrderedParts = [
|
||||
WBSContactStreetAddressLine2OrderedPartToken,
|
||||
WBSContactStreetAddressLine3OrderedPartToken,
|
||||
]))
|
||||
: e.length >= 3 &&
|
||||
((e[0].ControlOrderedParts = [
|
||||
WBSContactStreetAddressLine1OrderedPartToken,
|
||||
]),
|
||||
(e[1].ControlOrderedParts = [
|
||||
WBSContactStreetAddressLine2OrderedPartToken,
|
||||
]),
|
||||
(e[2].ControlOrderedParts = [
|
||||
WBSContactStreetAddressLine3OrderedPartToken,
|
||||
]));
|
||||
S = e.length;
|
||||
continue;
|
||||
}
|
||||
if (B === WBSContactInstantMessageClassificationToken) {
|
||||
const e = this.continuingFieldsInFormControls(t, k, !0, !0);
|
||||
(1 === e.length &&
|
||||
((e[0].ControlClassification =
|
||||
WBSContactInstantMessageClassificationToken),
|
||||
r && (e[0].ControlClassificationHints = [r])),
|
||||
(S = e.length));
|
||||
continue;
|
||||
}
|
||||
if (B.startsWith(WBSContactTelephoneClassificationToken)) {
|
||||
const e = this.continuingFieldsInFormControls(t, k, !0, !1);
|
||||
if (1 == e.length) {
|
||||
((e[0].ControlClassification =
|
||||
WBSContactTelephoneClassificationToken),
|
||||
(e[0].ControlOrderedParts = WBSTelephoneDefaultOrderedParts),
|
||||
r && (e[0].ControlClassificationHints = [r]));
|
||||
continue;
|
||||
}
|
||||
let o = ++u,
|
||||
n = 0;
|
||||
for (let t of e)
|
||||
((t.ControlClassification =
|
||||
WBSContactTelephoneClassificationToken),
|
||||
(t.ControlContinuationID = o),
|
||||
(t.ControlContinuationIndex = n++),
|
||||
r && (t.ControlClassificationHints = [r]));
|
||||
(2 === e.length
|
||||
? ((e[0].ControlOrderedParts = [
|
||||
WBSTelephoneAreaCodeOrderedPartToken,
|
||||
]),
|
||||
(e[1].ControlOrderedParts = [
|
||||
WBSTelephoneLocalPrefixOrderedPartToken,
|
||||
WBSTelephoneLocalSuffixOrderedPartToken,
|
||||
]))
|
||||
: 3 === e.length
|
||||
? ((e[0].ControlOrderedParts = [
|
||||
WBSTelephoneAreaCodeOrderedPartToken,
|
||||
]),
|
||||
(e[1].ControlOrderedParts = [
|
||||
WBSTelephoneLocalPrefixOrderedPartToken,
|
||||
]),
|
||||
(e[2].ControlOrderedParts = [
|
||||
WBSTelephoneLocalSuffixOrderedPartToken,
|
||||
]))
|
||||
: 4 === e.length
|
||||
? ((e[0].ControlOrderedParts = [
|
||||
WBSTelephoneCountryCodeOrderedPartToken,
|
||||
]),
|
||||
(e[1].ControlOrderedParts = [
|
||||
WBSTelephoneAreaCodeOrderedPartToken,
|
||||
]),
|
||||
(e[2].ControlOrderedParts = [
|
||||
WBSTelephoneLocalPrefixOrderedPartToken,
|
||||
]),
|
||||
(e[3].ControlOrderedParts = [
|
||||
WBSTelephoneLocalSuffixOrderedPartToken,
|
||||
]))
|
||||
: ((e[0].ControlOrderedParts = [
|
||||
WBSTelephoneCountryCodeOrderedPartToken,
|
||||
]),
|
||||
(e[1].ControlOrderedParts = [
|
||||
WBSTelephoneAreaCodeOrderedPartToken,
|
||||
]),
|
||||
(e[2].ControlOrderedParts = [
|
||||
WBSTelephoneLocalPrefixOrderedPartToken,
|
||||
]),
|
||||
(e[3].ControlOrderedParts = [
|
||||
WBSTelephoneLocalSuffixOrderedPartToken,
|
||||
]),
|
||||
(e[4].ControlOrderedParts = [
|
||||
WBSTelephoneExtensionOrderedPartToken,
|
||||
])),
|
||||
(S = e.length));
|
||||
continue;
|
||||
}
|
||||
if (B === WBSContactBirthdayClassificationToken) {
|
||||
const o = this.continuingFieldsInFormControls(t, k, !1, !1),
|
||||
r = o.length > 1 ? ++u : void 0,
|
||||
n =
|
||||
e.RequestType === WBSFormMetadataRequestTesting
|
||||
? "en-US"
|
||||
: void 0;
|
||||
(this.classifyDateFields(
|
||||
o,
|
||||
WBSContactBirthdayClassificationToken,
|
||||
WBSDateYearOrderedPartToken,
|
||||
WBSDateMonthOrderedPartToken,
|
||||
WBSDateDayOrderedPartToken,
|
||||
r,
|
||||
n,
|
||||
),
|
||||
(S = o.length));
|
||||
continue;
|
||||
}
|
||||
o.ControlClassification = B;
|
||||
} else
|
||||
o.ControlLooksLikeEIDField
|
||||
? (o.ControlClassification = WBSDeviceEIDClassificationToken)
|
||||
: o.ControlLooksLikeIMEIField
|
||||
? (o.ControlClassification = WBSDeviceIMEIClassificationToken)
|
||||
: o.ControlLooksLikeIMEI1Field
|
||||
? (o.ControlClassification =
|
||||
WBSDeviceIMEI1ClassificationToken)
|
||||
: o.ControlLooksLikeIMEI2Field
|
||||
? (o.ControlClassification =
|
||||
WBSDeviceIMEI2ClassificationToken)
|
||||
: o.ControlLooksLikeNALField &&
|
||||
(o.ControlClassification =
|
||||
WBSDeviceNALClassificationToken);
|
||||
else
|
||||
((f = !0),
|
||||
(o.ControlClassification = WBSCreditCardTypeClassificationToken));
|
||||
else
|
||||
((h = !0),
|
||||
(o.ControlClassification =
|
||||
WBSCreditCardSecurityCodeClassificationToken));
|
||||
}
|
||||
return e;
|
||||
}
|
||||
}
|
||||
globalThis.FormMetadataClassificationJS = new FormMetadataClassification();
|
||||
0;
|
||||
309
27.0/js/forms/FormMetadataContactsAutoFillMappings.js
Normal file
309
27.0/js/forms/FormMetadataContactsAutoFillMappings.js
Normal file
@@ -0,0 +1,309 @@
|
||||
//# sourceURL=__InjectedScript_FormMetadataContactsAutoFillMappings.js
|
||||
/* Copyright (c) 2026 Apple Inc. All rights reserved. */
|
||||
// Copyright (C) 2018-2025 Apple Inc. All rights reserved.
|
||||
function newAddressBookFieldLabelPatternMatchers() {
|
||||
return [
|
||||
new FormMetadataFieldPatternMatcher(
|
||||
window.webkit.buffers.addressBookFieldLabelPatternMatchers0,
|
||||
),
|
||||
new FormMetadataFieldPatternMatcher(
|
||||
window.webkit.buffers.addressBookFieldLabelPatternMatchers1,
|
||||
),
|
||||
new FormMetadataFieldPatternMatcher(
|
||||
window.webkit.buffers.addressBookFieldLabelPatternMatchers2,
|
||||
),
|
||||
new FormMetadataFieldPatternMatcher(
|
||||
window.webkit.buffers.addressBookFieldLabelPatternMatchers3,
|
||||
),
|
||||
];
|
||||
}
|
||||
function newEmailFieldLabelPatternMatchers() {
|
||||
return [
|
||||
new FormMetadataFieldPatternMatcher(
|
||||
window.webkit.buffers.emailFieldLabelPatternMatchers,
|
||||
),
|
||||
];
|
||||
}
|
||||
class ValueSpecifier {
|
||||
constructor(e, n, l, a, t, s, r) {
|
||||
((this.property = e),
|
||||
(this.component = n),
|
||||
(this.label = l),
|
||||
(this.category = a),
|
||||
(this.parentProperty = t),
|
||||
(this.classification = s),
|
||||
(this.classificationHint = r));
|
||||
}
|
||||
}
|
||||
var valueSpecifiers = [
|
||||
new ValueSpecifier(
|
||||
"FullNameComposite",
|
||||
null,
|
||||
null,
|
||||
"FullNameComposite",
|
||||
null,
|
||||
"name",
|
||||
null,
|
||||
),
|
||||
new ValueSpecifier(
|
||||
"First",
|
||||
null,
|
||||
null,
|
||||
"First",
|
||||
"FullNameComposite",
|
||||
"given-name",
|
||||
null,
|
||||
),
|
||||
new ValueSpecifier(
|
||||
"Middle",
|
||||
null,
|
||||
null,
|
||||
"Middle",
|
||||
"FullNameComposite",
|
||||
"additional-name",
|
||||
null,
|
||||
),
|
||||
new ValueSpecifier(
|
||||
"Last",
|
||||
null,
|
||||
null,
|
||||
"Last",
|
||||
"FullNameComposite",
|
||||
"family-name",
|
||||
null,
|
||||
),
|
||||
new ValueSpecifier("Birthday", null, null, "Birthday", null, "bday", null),
|
||||
new ValueSpecifier(
|
||||
"JobTitle",
|
||||
null,
|
||||
null,
|
||||
"JobTitle",
|
||||
null,
|
||||
"organization-title",
|
||||
null,
|
||||
),
|
||||
new ValueSpecifier("Email", null, null, "Email", null, "email", null),
|
||||
new ValueSpecifier(
|
||||
"Address",
|
||||
"Street",
|
||||
null,
|
||||
"AddressStreet",
|
||||
null,
|
||||
"street-address",
|
||||
null,
|
||||
),
|
||||
new ValueSpecifier(
|
||||
"Address",
|
||||
"City",
|
||||
null,
|
||||
"AddressCity",
|
||||
null,
|
||||
"address-level2",
|
||||
null,
|
||||
),
|
||||
new ValueSpecifier(
|
||||
"Address",
|
||||
"State",
|
||||
null,
|
||||
"AddressState",
|
||||
null,
|
||||
"address-level1",
|
||||
null,
|
||||
),
|
||||
new ValueSpecifier(
|
||||
"Address",
|
||||
"ZIP",
|
||||
null,
|
||||
"AddressZIP",
|
||||
null,
|
||||
"postal-code",
|
||||
null,
|
||||
),
|
||||
new ValueSpecifier(
|
||||
"Address",
|
||||
"Country",
|
||||
null,
|
||||
"AddressCountry",
|
||||
null,
|
||||
"country",
|
||||
null,
|
||||
),
|
||||
new ValueSpecifier(
|
||||
"Phone",
|
||||
null,
|
||||
null,
|
||||
"Phone",
|
||||
null,
|
||||
"tel-area-code",
|
||||
null,
|
||||
),
|
||||
new ValueSpecifier("Phone", null, null, "Phone", null, "tel", null),
|
||||
new ValueSpecifier(
|
||||
"Organization",
|
||||
null,
|
||||
null,
|
||||
"Organization",
|
||||
null,
|
||||
"organization",
|
||||
null,
|
||||
),
|
||||
new ValueSpecifier(
|
||||
"URLs",
|
||||
null,
|
||||
"_$!<HomePage>!$_",
|
||||
"URLs_$!<HomePage>!$_",
|
||||
null,
|
||||
"url",
|
||||
null,
|
||||
),
|
||||
new ValueSpecifier(
|
||||
"Phone",
|
||||
null,
|
||||
"_$!<Home>!$_",
|
||||
"Phone_$!<Home>!$_",
|
||||
null,
|
||||
"tel",
|
||||
"home",
|
||||
),
|
||||
new ValueSpecifier(
|
||||
"Phone",
|
||||
null,
|
||||
"_$!<Work>!$_",
|
||||
"Phone_$!<Work>!$_",
|
||||
null,
|
||||
"tel",
|
||||
"work",
|
||||
),
|
||||
new ValueSpecifier(
|
||||
"Phone",
|
||||
null,
|
||||
"_$!<Mobile>!$_",
|
||||
"Phone_$!<Mobile>!$_",
|
||||
null,
|
||||
"tel",
|
||||
"mobile",
|
||||
),
|
||||
new ValueSpecifier(
|
||||
"Phone",
|
||||
null,
|
||||
"_$!<Pager>!$_",
|
||||
"Phone_$!<Pager>!$_",
|
||||
null,
|
||||
"tel",
|
||||
"pager",
|
||||
),
|
||||
new ValueSpecifier("Phone", null, null, "Phone", null, "tel", "fax"),
|
||||
new ValueSpecifier("<Invalid>", null, null, "<Invalid>", null, null, null),
|
||||
new ValueSpecifier(
|
||||
"InstantMessage",
|
||||
"AIMInstant",
|
||||
null,
|
||||
"InstantMessageAIMInstant",
|
||||
null,
|
||||
"-sf-instant-message",
|
||||
"-sf-aim",
|
||||
),
|
||||
new ValueSpecifier(
|
||||
"InstantMessage",
|
||||
"ICQInstant",
|
||||
null,
|
||||
"InstantMessageICQInstant",
|
||||
null,
|
||||
"-sf-instant-message",
|
||||
"-sf-icq",
|
||||
),
|
||||
new ValueSpecifier(
|
||||
"InstantMessage",
|
||||
"JabberInstant",
|
||||
null,
|
||||
"InstantMessageJabberInstant",
|
||||
null,
|
||||
"-sf-instant-message",
|
||||
"-sf-jabber",
|
||||
),
|
||||
new ValueSpecifier(
|
||||
"InstantMessage",
|
||||
"MSNInstant",
|
||||
null,
|
||||
"InstantMessageMSNInstant",
|
||||
null,
|
||||
"-sf-instant-message",
|
||||
"-sf-msn",
|
||||
),
|
||||
new ValueSpecifier(
|
||||
"InstantMessage",
|
||||
"QQInstant",
|
||||
null,
|
||||
"InstantMessageQQInstant",
|
||||
null,
|
||||
"-sf-instant-message",
|
||||
"-sf-qq",
|
||||
),
|
||||
new ValueSpecifier(
|
||||
"InstantMessage",
|
||||
"SkypeInstant",
|
||||
null,
|
||||
"InstantMessageSkypeInstant",
|
||||
null,
|
||||
"-sf-instant-message",
|
||||
"-sf-skype",
|
||||
),
|
||||
],
|
||||
FormAutoFillKeywords = {
|
||||
NonAutoFillableFormTypeRegularExpressions: ["[\\b-]import[\\b-]"],
|
||||
LoginFormTypeKeywords: {
|
||||
"@me": 1,
|
||||
"welcome back": 1,
|
||||
"log on": 1,
|
||||
log_on: 1,
|
||||
"sign on": 1,
|
||||
login: 1,
|
||||
signon: 1,
|
||||
"log in": 1,
|
||||
"sign in": 1,
|
||||
signin: 1,
|
||||
"forgot user": 1,
|
||||
"enter your current password": 2,
|
||||
"enter your password": 2,
|
||||
reauth: 2,
|
||||
"\u767b\u5f55": 1,
|
||||
"\u767b\u5165": 1,
|
||||
"iniciar sesi\xf3n": 1,
|
||||
anmelden: 1,
|
||||
absenden: 1,
|
||||
connexion: 1,
|
||||
"logg inn": 1,
|
||||
"\u0e40\u0e02\u0e49\u0e32\u0e2a\u0e39\u0e48\u0e23\u0e30\u0e1a\u0e1a": 1,
|
||||
},
|
||||
NewAccountFormTypeKeywords: {
|
||||
"set up": 1,
|
||||
setup: 1,
|
||||
signup: 1,
|
||||
"sign up": 1,
|
||||
create: 1,
|
||||
"create account": 1,
|
||||
"create an account": 1,
|
||||
enrollment: 1,
|
||||
reg: 1,
|
||||
activate: 1,
|
||||
"\u6ce8\u518c": 1,
|
||||
"\u0e2a\u0e21\u0e31\u0e04\u0e23\u0e2a\u0e21\u0e32\u0e0a\u0e34\u0e01": 1,
|
||||
},
|
||||
ChangePasswordFormTypeKeywords: {
|
||||
forgotpassword: 1,
|
||||
"forgot password": 1,
|
||||
reset: 1,
|
||||
update: 1,
|
||||
change: 1,
|
||||
"\u518d\u8a2d\u5b9a": 1,
|
||||
cambiar: 1,
|
||||
},
|
||||
ForgotPasswordAffordanceRegularExpressions: [
|
||||
"^forgot.*password",
|
||||
"^log.*in.*email",
|
||||
"request.*password",
|
||||
],
|
||||
ForgotUserNameAffordanceRegularExpressions: ["^forgot.*user.*name"],
|
||||
ForgotEmailAffordanceRegularExpressions: ["^forgot.*email", "email\\?$"],
|
||||
};
|
||||
0;
|
||||
657
27.0/js/forms/FormMetadataJSController.js
Normal file
657
27.0/js/forms/FormMetadataJSController.js
Normal file
@@ -0,0 +1,657 @@
|
||||
//# sourceURL=__InjectedScript_FormMetadataJSController.js
|
||||
/* Copyright (c) 2026 Apple Inc. All rights reserved. */
|
||||
"use strict";
|
||||
const WBSMinimumLogicalWidthToShowManualAutoFillButton = 100,
|
||||
WKInputFieldActionTypeMoveUp = 0,
|
||||
WKInputFieldActionTypeMoveDown = 1,
|
||||
WKInputFieldActionTypeCancel = 2,
|
||||
WKInputFieldActionTypeInsertTab = 3,
|
||||
WKInputFieldActionTypeInsertBacktab = 4,
|
||||
WKInputFieldActionTypeInsertNewline = 5,
|
||||
WKInputFieldActionTypeInsertDelete = 6,
|
||||
textDidChangeCoalescingTime = 100;
|
||||
class FormMetadataFieldPatternMatcher {
|
||||
searchRegularExpression;
|
||||
constructor(e) {
|
||||
this.buffer = e;
|
||||
}
|
||||
dfa() {
|
||||
return this.buffer.asUTF16String();
|
||||
}
|
||||
}
|
||||
class FormMetadataJSController {
|
||||
static isDebugConsoleLoggingEnabled =
|
||||
AutoFillControllerConfig.isDebugConsoleLoggingEnabled;
|
||||
static collectAllFields = AutoFillControllerConfig.collectAllFields;
|
||||
static _nextControlUniqueID = 1;
|
||||
static get nextControlUniqueID() {
|
||||
return this._nextControlUniqueID++;
|
||||
}
|
||||
static _nextFormUniqueID = 1;
|
||||
static get nextFormUniqueID() {
|
||||
return this._nextFormUniqueID++;
|
||||
}
|
||||
static regularExpressionsIndicatingNonAutoFillableFormType =
|
||||
FormAutoFillKeywords.NonAutoFillableFormTypeRegularExpressions;
|
||||
static loginFormTypePatternMatchers = [
|
||||
new FormMetadataFieldPatternMatcher(
|
||||
window.webkit.buffers.keywordsIndicatingLoginFormTypeToScoreForMatching,
|
||||
),
|
||||
];
|
||||
static oneTimeCodeFieldLabelPatternMatchers = [
|
||||
new FormMetadataFieldPatternMatcher(
|
||||
window.webkit.buffers.oneTimeCodeFieldLabels,
|
||||
),
|
||||
];
|
||||
static nonAccountPasswordSecureTextEntryFieldLabelPatternMatchers = [
|
||||
new FormMetadataFieldPatternMatcher(
|
||||
window.webkit.buffers.nonAccountPasswordSecureTextEntryFieldLabels,
|
||||
),
|
||||
];
|
||||
static ignoredDataTypeFieldLabelPatternMatchers = [
|
||||
new FormMetadataFieldPatternMatcher(
|
||||
window.webkit.buffers.ignoredDataTypeFieldLabels,
|
||||
),
|
||||
];
|
||||
static genericAdditionalClassificationLabelPatternMatchers = [
|
||||
new FormMetadataFieldPatternMatcher(
|
||||
window.webkit.buffers.genericAdditionalClassificationLabels,
|
||||
),
|
||||
];
|
||||
static additionalClassificationControlLabelPatternMatchers = [
|
||||
new FormMetadataFieldPatternMatcher(
|
||||
window.webkit.buffers.additionalClassificationControlLabels,
|
||||
),
|
||||
];
|
||||
static oldPasswordFieldLabelPatternMatchers = [
|
||||
new FormMetadataFieldPatternMatcher(
|
||||
window.webkit.buffers.oldPasswordFieldLabels,
|
||||
),
|
||||
];
|
||||
static confirmPasswordFieldLabelPatternMatchers = [
|
||||
new FormMetadataFieldPatternMatcher(
|
||||
window.webkit.buffers.confirmPasswordFieldLabels,
|
||||
),
|
||||
];
|
||||
static confirmEmailFieldLabelPatternMatchers = [
|
||||
new FormMetadataFieldPatternMatcher(
|
||||
window.webkit.buffers.confirmEmailFieldLabels,
|
||||
),
|
||||
];
|
||||
static showHideButtonLabelPatternMatchers = [
|
||||
new FormMetadataFieldPatternMatcher(
|
||||
window.webkit.buffers.showHideButtonLabels,
|
||||
),
|
||||
];
|
||||
static searchFieldLabelPatternMatchers = [
|
||||
new FormMetadataFieldPatternMatcher(
|
||||
window.webkit.buffers.searchFieldLabels,
|
||||
),
|
||||
];
|
||||
static nonUsernameFieldLabelPatternMatchers = [
|
||||
new FormMetadataFieldPatternMatcher(
|
||||
window.webkit.buffers.nonUsernameFieldLabels,
|
||||
),
|
||||
];
|
||||
static passwordFieldLabelPatternMatchers = [
|
||||
new FormMetadataFieldPatternMatcher(
|
||||
window.webkit.buffers.passwordFieldLabels,
|
||||
),
|
||||
];
|
||||
static usernameFieldLabelPatternMatchers = [
|
||||
new FormMetadataFieldPatternMatcher(
|
||||
window.webkit.buffers.usernameFieldLabels,
|
||||
),
|
||||
];
|
||||
static nonEmailFieldLabelPatternMatchers = [
|
||||
new FormMetadataFieldPatternMatcher(
|
||||
window.webkit.buffers.nonEmailFieldLabels,
|
||||
),
|
||||
];
|
||||
static weakOneTimeCodeFieldLabelPatternMatchers = [
|
||||
new FormMetadataFieldPatternMatcher(
|
||||
window.webkit.buffers.WeakOneTimeCodeFieldLabels,
|
||||
),
|
||||
];
|
||||
static codeButNotOneTimeCodeFieldLabelsPatternMatchers = [
|
||||
new FormMetadataFieldPatternMatcher(
|
||||
window.webkit.buffers.CodeButNotOneTimeCodeFieldLabels,
|
||||
),
|
||||
];
|
||||
static dayFieldLabelPatternMatchers = [
|
||||
new FormMetadataFieldPatternMatcher(window.webkit.buffers.dayFieldLabels),
|
||||
];
|
||||
static monthFieldLabelPatternMatchers = [
|
||||
new FormMetadataFieldPatternMatcher(window.webkit.buffers.monthFieldLabels),
|
||||
];
|
||||
static yearFieldLabelPatternMatchers = [
|
||||
new FormMetadataFieldPatternMatcher(window.webkit.buffers.yearFieldLabels),
|
||||
];
|
||||
static addressBookFieldLabelPatternMatchers =
|
||||
newAddressBookFieldLabelPatternMatchers();
|
||||
static emailFieldLabelPatternMatchers = newEmailFieldLabelPatternMatchers();
|
||||
static creditCardNumberFieldLabelPatternMatchers = [
|
||||
new FormMetadataFieldPatternMatcher(
|
||||
window.webkit.buffers.creditCardNumberFieldLabels,
|
||||
),
|
||||
];
|
||||
static creditCardSecurityCodeFieldLabelPatternMatchers = [
|
||||
new FormMetadataFieldPatternMatcher(
|
||||
window.webkit.buffers.creditCardSecurityCodeFieldLabels,
|
||||
),
|
||||
];
|
||||
static creditCardCardholderFieldLabelPatternMatchers = [
|
||||
new FormMetadataFieldPatternMatcher(
|
||||
window.webkit.buffers.creditCardCardholderFieldLabels,
|
||||
),
|
||||
];
|
||||
static creditCardTypeFieldLabelPatternMatchers = [
|
||||
new FormMetadataFieldPatternMatcher(
|
||||
window.webkit.buffers.creditCardTypeFieldLabels,
|
||||
),
|
||||
];
|
||||
static nonCreditCardCardNumberFieldLabelPatternMatchers = [
|
||||
new FormMetadataFieldPatternMatcher(
|
||||
window.webkit.buffers.nonCreditCardCardNumberFieldLabels,
|
||||
),
|
||||
];
|
||||
static creditCardCompositeExpirationDateFieldLabelPatternMatchers = [
|
||||
new FormMetadataFieldPatternMatcher(
|
||||
window.webkit.buffers.creditCardCompositeExpirationDateFieldLabels,
|
||||
),
|
||||
];
|
||||
static newAccountFormTypePatternMatchers = [
|
||||
new FormMetadataFieldPatternMatcher(
|
||||
window.webkit.buffers
|
||||
.keywordsIndicatingNewAccountFormTypeToScoreForMatching,
|
||||
),
|
||||
];
|
||||
static federatedSignInAffordancePatternMatchers = [
|
||||
new FormMetadataFieldPatternMatcher(
|
||||
window.webkit.buffers.federatedSignInAffordanceLabels,
|
||||
),
|
||||
];
|
||||
static mapOfKeywordsIndicatingLoginFormTypeToScoreForMatching =
|
||||
FormAutoFillKeywords.LoginFormTypeKeywords;
|
||||
static mapOfKeywordsIndicatingNewAccountFormTypeToScoreForMatching =
|
||||
FormAutoFillKeywords.NewAccountFormTypeKeywords;
|
||||
static mapOfKeywordsIndicatingChangePasswordFormTypeToScoreForMatching =
|
||||
FormAutoFillKeywords.ChangePasswordFormTypeKeywords;
|
||||
static regularExpressionsForForgotPasswordAffordance =
|
||||
FormAutoFillKeywords.ForgotPasswordAffordanceRegularExpressions;
|
||||
static regularExpressionsForForgotUserNameAffordance =
|
||||
FormAutoFillKeywords.ForgotUserNameAffordanceRegularExpressions;
|
||||
static regularExpressionsForForgotEmailAffordance =
|
||||
FormAutoFillKeywords.ForgotEmailAffordanceRegularExpressions;
|
||||
autoFillButtonManager;
|
||||
focusManager;
|
||||
didAssociateFormControlsTimeout;
|
||||
constructor() {
|
||||
((this.focusManager = new FocusManager(this)),
|
||||
this.focusManager.addEventListeners(),
|
||||
(this.autoFillButtonManager = new AutoFillButtonManager(this)),
|
||||
this.autoFillButtonManager.addEventListeners(),
|
||||
(this.didAssociateFormControlsTimeout = null),
|
||||
addGlobalEventHandler(
|
||||
"webkitassociateformcontrols",
|
||||
this.didAssociateFormControls.bind(this),
|
||||
),
|
||||
(this.shouldNotifyOnFormChanges = !1),
|
||||
window.addEventListener("pagehide", () => {
|
||||
this.focusManager.cleanUp();
|
||||
let e = null;
|
||||
(document.activeElement instanceof HTMLInputElement &&
|
||||
(e = FormMetadataJS.textFieldOrSelectElementMetadata(
|
||||
document.activeElement,
|
||||
WBSFormMetadataRequestNormal,
|
||||
)[0]),
|
||||
window.webkit.messageHandlers.controller.postMessage({
|
||||
name: "pageHide",
|
||||
focusedControlMetadata: e,
|
||||
}));
|
||||
}));
|
||||
}
|
||||
didAssociateFormControls(e) {
|
||||
if (!this.shouldNotifyOnFormChanges) return;
|
||||
if (this.didAssociateFormControlsTimeout) return;
|
||||
const t = e.composedPath()[0];
|
||||
if ("hidden" === t.type || "button" === t.type) return;
|
||||
const [a, o] = FormMetadataJS.formsAndMetadata(
|
||||
WBSFormMetadataRequestPreFill,
|
||||
);
|
||||
this.didAssociateFormControlsTimeout = setTimeout(
|
||||
this.sendDidAssociateFormControlsMessage.bind(this),
|
||||
0,
|
||||
);
|
||||
}
|
||||
sendDidAssociateFormControlsMessage() {
|
||||
((this.didAssociateFormControlsTimeout = null),
|
||||
window.webkit.messageHandlers.controller.postMessage({
|
||||
name: "didAssociateFormControls",
|
||||
}));
|
||||
}
|
||||
textEditingStatus() {
|
||||
const [e, t] = FormMetadataJS.visibleNonEmptyFormTextControls(),
|
||||
a = e.filter((e) => e.lastChangeWasUserEdit),
|
||||
o = t.filter((e) => e.lastChangeWasUserEdit),
|
||||
r = document.body.onbeforeunload,
|
||||
n = null != r;
|
||||
return {
|
||||
numberOfTextInputElements: a.length,
|
||||
numberOfTextAreaElements: o.length,
|
||||
hasOnBeforeUnloadEventHandler: n,
|
||||
};
|
||||
}
|
||||
async fillFormWithPassword(e, t, a, o) {
|
||||
const r = await FormMetadataJS.fillFormWithPassword(e, a, t);
|
||||
if (r)
|
||||
for (const e of r) {
|
||||
const t = FormMetadataJS.formControlWithUniqueID(e);
|
||||
t && (t.autofillVisibility = o ? "hidden" : "visible");
|
||||
}
|
||||
o && AutomaticPasswordsJS.blurControlWithID(t);
|
||||
let n = null;
|
||||
const i = FormMetadataJS.formsAndMetadata(WBSFormMetadataRequestNormal)[1];
|
||||
for (const t of i)
|
||||
if (t.FormID === e) {
|
||||
n = t;
|
||||
break;
|
||||
}
|
||||
return { controlIDs: r, formMetadata: n };
|
||||
}
|
||||
static #e(e) {
|
||||
const t = getComputedStyle(e).writingMode,
|
||||
a = !("horizontal-tb" === t || "horizontal-bt" === t),
|
||||
o = e.getBoundingClientRect();
|
||||
return (
|
||||
(a ? o.height : o.width) >=
|
||||
WBSMinimumLogicalWidthToShowManualAutoFillButton
|
||||
);
|
||||
}
|
||||
static #t(e) {
|
||||
return !!FormMetadataJSController.#e(e) && e === innermostActiveElement();
|
||||
}
|
||||
static autocompleteTokenMapDFA() {
|
||||
return window.webkit.buffers.autocompleteTokenMapMatcher.asUTF16String();
|
||||
}
|
||||
static fieldLabelMapDFA() {
|
||||
return window.webkit.buffers.fieldLabelMapMatcher.asUTF16String();
|
||||
}
|
||||
static getValueSpecifiers(e) {
|
||||
return valueSpecifiers[e];
|
||||
}
|
||||
showAutoFillButtonInControl(e, t) {
|
||||
const a = FormMetadataJS.formControlWithUniqueID(e);
|
||||
(FormMetadataJSController.#t(a) || "none" === t) &&
|
||||
a._setAutofillButtonType(t);
|
||||
}
|
||||
hideAutoFillButtonInControl(e) {
|
||||
FormMetadataJS.formControlWithUniqueID(e)._setAutofillButtonType("none");
|
||||
}
|
||||
setAutofillAvailable(e, t) {
|
||||
const a = FormMetadataJS.formControlWithUniqueID(e);
|
||||
a && (a.autofillAvailable = t);
|
||||
}
|
||||
setControlsAsAutoFilled(e, t) {
|
||||
this.#a(e).forEach((e) => {
|
||||
FormMetadataJSController.setInputElementAutofilled(e, t);
|
||||
});
|
||||
}
|
||||
blurControls(e) {
|
||||
this.#a(e).forEach((e) => e.blur());
|
||||
}
|
||||
clearControls(e) {
|
||||
e.forEach((e) => FormMetadataJS.clearField(e));
|
||||
}
|
||||
annotateForm(e, t) {
|
||||
FormMetadataJS.annotateFormWithID(e, t);
|
||||
}
|
||||
formsMetadata(e) {
|
||||
(e !== WBSFormMetadataRequestPreFill &&
|
||||
e !== WBSFormMetadataRequestTesting) ||
|
||||
(this.shouldNotifyOnFormChanges = !0);
|
||||
let [t, a] = FormMetadataJS.formsAndMetadata(e);
|
||||
for (const e of a)
|
||||
for (const t of e.FormControls) {
|
||||
const e = FormMetadataJS.formControlWithUniqueID(t.ControlUniqueID);
|
||||
this.populateRectFieldsInFormElementMetadata(t, e);
|
||||
}
|
||||
return a;
|
||||
}
|
||||
getMetadataForFocusedElement(e = WBSFormMetadataRequestNormal) {
|
||||
const t = innermostActiveElement();
|
||||
return t ? this._getMetadataForControl(t, e) : [null, null];
|
||||
}
|
||||
getMetadataForControl(e, t = WBSFormMetadataRequestNormal) {
|
||||
const a = FormMetadataJS.formControlWithUniqueID(e);
|
||||
return a ? this._getMetadataForControl(a, t) : [null, null];
|
||||
}
|
||||
static #o(e) {
|
||||
let t = 0;
|
||||
const a = e.FirstCreditCardCardholderFieldOrCreditCardNumberFieldUniqueID,
|
||||
o = e.UserNameElementUniqueID,
|
||||
r = e.PasswordElementUniqueID,
|
||||
n = e.ConfirmPasswordElementUniqueID,
|
||||
i = 1,
|
||||
l = 10;
|
||||
if ((a && (t += i), o && (t += i), r && (t += i), n && (t += i), !t))
|
||||
return t;
|
||||
for (const i of e.FormControls) {
|
||||
const e = i.ControlUniqueID;
|
||||
if (e === a || e === o || e === r || e === n) {
|
||||
i.ControlValue && (t += l);
|
||||
}
|
||||
}
|
||||
return t;
|
||||
}
|
||||
getMetadataForForm(e) {
|
||||
const [t, a] = FormMetadataJS.formsAndMetadata(
|
||||
WBSFormMetadataRequestNormal,
|
||||
);
|
||||
let o = -1,
|
||||
r = null;
|
||||
for (let n = 0; n < t.length; n++)
|
||||
if (t[n] === e) {
|
||||
const e = a[n],
|
||||
t = FormMetadataJSController.#o(e);
|
||||
t > o && ((o = t), (r = e));
|
||||
}
|
||||
return r;
|
||||
}
|
||||
_getMetadataForControl(e, t) {
|
||||
let [a, o] = FormMetadataJS.textFieldOrSelectElementMetadata(e, t);
|
||||
return (this.populateRectFieldsInFormElementMetadata(a, e), [a, o]);
|
||||
}
|
||||
focusControl(e, t = !1) {
|
||||
FormMetadataJS.focusControl(e, t);
|
||||
}
|
||||
replaceRangeInControl(e, t, a, o, r) {
|
||||
FormMetadataJS.replaceFormFieldRangeAndSelectTail(e, t, a, o, r);
|
||||
const n = FormMetadataJS.formControlWithUniqueID(e);
|
||||
if (n)
|
||||
return FormMetadataJS.textFieldOrSelectElementMetadata(
|
||||
n,
|
||||
WBSFormMetadataRequestNormal,
|
||||
);
|
||||
}
|
||||
selectRangeInControl(e, t, a) {
|
||||
FormMetadataJS.setFormFieldSelection(e, t, a);
|
||||
}
|
||||
static setInputElementSpellCheckEnabled(e, t) {
|
||||
e.autofillSpellcheck = !!t;
|
||||
}
|
||||
static setInputElementAutofilled(e, t) {
|
||||
((e.autofilled = t),
|
||||
t && FormMetadataJSController.autoFilledFieldWithMetadata(e));
|
||||
}
|
||||
static setInputElementAutoFilledAndViewable(e, t) {
|
||||
e.autofilledAndViewable = t;
|
||||
}
|
||||
static setInputElementAutofilledAndObscured(e, t) {
|
||||
((e.autofilledAndObscured = t),
|
||||
t && FormMetadataJSController.autoFilledFieldWithMetadata(e));
|
||||
}
|
||||
populateRectFieldsInFormElementMetadata(e, t) {
|
||||
const a = t.getBoundingClientRect();
|
||||
((e.ControlRectLeft = a.left),
|
||||
(e.ControlRectTop = a.top),
|
||||
(e.ControlRectWidth = a.width),
|
||||
(e.ControlRectHeight = a.height));
|
||||
}
|
||||
#a(e) {
|
||||
return e.flatMap((e) => FormMetadataJS.formControlWithUniqueID(e));
|
||||
}
|
||||
static autoFilledFieldWithMetadata(e) {
|
||||
let [t, a] = FormMetadataJS.textFieldOrSelectElementMetadata(
|
||||
e,
|
||||
WBSFormMetadataRequestNormal,
|
||||
);
|
||||
window.webkit.messageHandlers.controller.postMessage({
|
||||
name: "autoFilledFieldWithMetadata",
|
||||
controlMetadata: t,
|
||||
formMetadata: a,
|
||||
});
|
||||
}
|
||||
static logicalFormObservedChangeIndicatingFormSubmission(e, t) {
|
||||
window.webkit.messageHandlers.controller.postMessage({
|
||||
name: "formObservedChangeIndicatingFormSubmission",
|
||||
formMetadata: e,
|
||||
removedControlsMetadata: t,
|
||||
});
|
||||
}
|
||||
static logicalFormObservedNewControlsWereAdded(e) {
|
||||
window.webkit.messageHandlers.controller.postMessage({
|
||||
name: "formObservedNewControlsWereAdded",
|
||||
formMetadata: e,
|
||||
});
|
||||
}
|
||||
static fieldLabelToInfo(e) {
|
||||
if (void 0 === e) return null;
|
||||
const [t, a] = e;
|
||||
if (t === 65535) return [a, "", "", ""];
|
||||
const o = valueSpecifiers[t];
|
||||
return [a, o.property, o.category, o.parentProperty];
|
||||
}
|
||||
}
|
||||
class FieldMovementChecker {
|
||||
textField;
|
||||
textFieldMetadata;
|
||||
formMetadata;
|
||||
numberOfTimesFieldMovementTimerHasFired;
|
||||
checkForFieldMovementTimeout;
|
||||
pollingIntervals;
|
||||
onFieldMoved;
|
||||
constructor(e) {
|
||||
((this.textField = null),
|
||||
(this.textFieldMetadata = null),
|
||||
(this.numberOfTimesFieldMovementTimerHasFired = 0),
|
||||
(this.checkForFieldMovementTimeout = null),
|
||||
(this.pollingIntervals = [10, 50, 100, 850]),
|
||||
(this.onFieldMoved = e));
|
||||
}
|
||||
setTextFieldToMonitor(e, t, a) {
|
||||
((this.textField = e),
|
||||
(this.textFieldMetadata = t),
|
||||
(this.formMetadata = a));
|
||||
}
|
||||
performNextCheckForFieldMovement() {
|
||||
if (
|
||||
((this.checkForFieldMovementTimeout = null),
|
||||
!this.textField || !this.textFieldMetadata)
|
||||
)
|
||||
return void this.reset();
|
||||
const e = this.textField.getBoundingClientRect();
|
||||
(this.textFieldMetadata.ControlRectLeft != e.left ||
|
||||
this.textFieldMetadata.ControlRectTop != e.top ||
|
||||
this.textFieldMetadata.ControlRectWidth != e.width ||
|
||||
this.textFieldMetadata.ControlRectHeight != e.height
|
||||
? (this.onFieldMoved(
|
||||
this.textField,
|
||||
this.textFieldMetadata,
|
||||
this.formMetadata,
|
||||
),
|
||||
(this.numberOfTimesFieldMovementTimerHasFired = 0))
|
||||
: (this.numberOfTimesFieldMovementTimerHasFired += 1),
|
||||
this.numberOfTimesFieldMovementTimerHasFired >=
|
||||
this.pollingIntervals.length
|
||||
? this.reset()
|
||||
: this.scheduleNextCheckForFieldMovement());
|
||||
}
|
||||
reset() {
|
||||
(this.checkForFieldMovementTimeout &&
|
||||
window.clearTimeout(this.checkForFieldMovementTimeout),
|
||||
(this.checkForFieldMovementTimeout = null));
|
||||
}
|
||||
scheduleNextCheckForFieldMovement() {
|
||||
this.reset();
|
||||
const e =
|
||||
this.pollingIntervals[this.numberOfTimesFieldMovementTimerHasFired];
|
||||
this.checkForFieldMovementTimeout = window.setTimeout(
|
||||
this.performNextCheckForFieldMovement.bind(this),
|
||||
e,
|
||||
);
|
||||
}
|
||||
}
|
||||
class EventDispatcher {
|
||||
#r = new Map();
|
||||
addGlobalListener(e, t) {
|
||||
(this.#r.has(e) || this.#r.set(e, new Set()), this.#r.get(e).add(t));
|
||||
}
|
||||
dispatchEvent(e) {
|
||||
if (this.#r.has(e.type))
|
||||
for (const t of this.#r.get(e.type)) t(e.target, e.data);
|
||||
}
|
||||
}
|
||||
const formMetadataEventDispatcher = new EventDispatcher();
|
||||
class FocusManager {
|
||||
jsController;
|
||||
fieldMovementChecker;
|
||||
#n = null;
|
||||
constructor(e) {
|
||||
((this.jsController = e),
|
||||
(this.fieldMovementChecker = new FieldMovementChecker(
|
||||
this.handleElementFocused.bind(this),
|
||||
)));
|
||||
}
|
||||
addEventListeners() {
|
||||
(formMetadataEventDispatcher.addGlobalListener(
|
||||
"webkitsubmit",
|
||||
this.submitEventHandler.bind(this),
|
||||
),
|
||||
formMetadataEventDispatcher.addGlobalListener(
|
||||
"webkitbeforefocus",
|
||||
this.focusInEventHandler.bind(this),
|
||||
),
|
||||
formMetadataEventDispatcher.addGlobalListener(
|
||||
"webkitbeforeblur",
|
||||
this.focusOutEventHandler.bind(this),
|
||||
),
|
||||
formMetadataEventDispatcher.addGlobalListener(
|
||||
"webkitusertextinput",
|
||||
this.inputEventHandler.bind(this),
|
||||
),
|
||||
formMetadataEventDispatcher.addGlobalListener(
|
||||
"keydown",
|
||||
this.keydownEventHandler.bind(this),
|
||||
));
|
||||
}
|
||||
focusInEventHandler(e) {
|
||||
this.fieldMovementChecker.reset();
|
||||
let [t, a] = FormMetadataJS.textFieldOrSelectElementMetadata(
|
||||
e,
|
||||
WBSFormMetadataRequestNormal,
|
||||
);
|
||||
t &&
|
||||
(e.setUserInfo({ form: a, textField: t }),
|
||||
this.fieldMovementChecker.setTextFieldToMonitor(e, t, a),
|
||||
this.fieldMovementChecker.scheduleNextCheckForFieldMovement(),
|
||||
this.handleElementFocused(e, t, a));
|
||||
}
|
||||
handleElementFocused(e, t, a) {
|
||||
(this.jsController.populateRectFieldsInFormElementMetadata(t, e),
|
||||
window.webkit.messageHandlers.controller.postMessage({
|
||||
name: "elementFocused",
|
||||
focusedElementMetadata: t,
|
||||
formMetadata: a,
|
||||
}));
|
||||
}
|
||||
focusOutEventHandler(e) {
|
||||
this.fieldMovementChecker.reset();
|
||||
let [t, a] = FormMetadataJS.textFieldOrSelectElementMetadata(
|
||||
e,
|
||||
WBSFormMetadataRequestNormal,
|
||||
);
|
||||
t &&
|
||||
window.webkit.messageHandlers.controller.postMessage({
|
||||
name: "elementBlurred",
|
||||
focusedElementMetadata: t,
|
||||
formMetadata: a,
|
||||
});
|
||||
}
|
||||
cleanUp() {
|
||||
this.#n && (clearTimeout(this.#n), (this.#n = null));
|
||||
}
|
||||
inputEventHandler(e) {
|
||||
(this.#n && clearTimeout(this.#n),
|
||||
(this.#n = setTimeout(() => {
|
||||
this.#i(e);
|
||||
}, textDidChangeCoalescingTime)));
|
||||
}
|
||||
#i(e) {
|
||||
let [t, a] = FormMetadataJS.textFieldOrSelectElementMetadata(
|
||||
e,
|
||||
WBSFormMetadataRequestTextChange,
|
||||
);
|
||||
t &&
|
||||
(this.jsController.populateRectFieldsInFormElementMetadata(t, e),
|
||||
window.webkit.messageHandlers.controller.postMessage({
|
||||
name: "elementInput",
|
||||
focusedElementMetadata: t,
|
||||
formMetadata: a,
|
||||
}));
|
||||
}
|
||||
static #l(e, t) {
|
||||
switch (e) {
|
||||
case "ArrowUp":
|
||||
return WKInputFieldActionTypeMoveUp;
|
||||
case "ArrowDown":
|
||||
return WKInputFieldActionTypeMoveDown;
|
||||
case "Escape":
|
||||
return WKInputFieldActionTypeCancel;
|
||||
case "Tab":
|
||||
return t
|
||||
? WKInputFieldActionTypeInsertBacktab
|
||||
: WKInputFieldActionTypeInsertTab;
|
||||
case "Enter":
|
||||
return WKInputFieldActionTypeInsertNewline;
|
||||
case "Backspace":
|
||||
return WKInputFieldActionTypeInsertDelete;
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
keydownEventHandler(e, t) {
|
||||
const a = FocusManager.#l(t.key, t.shiftKey);
|
||||
if (null === a) return;
|
||||
const [o, r] = this.jsController._getMetadataForControl(
|
||||
e,
|
||||
WBSFormMetadataRequestNormal,
|
||||
);
|
||||
window.webkit.messageHandlers.controller.postMessage({
|
||||
name: "observedActionInFormTextField",
|
||||
action: a,
|
||||
controlMetadata: o,
|
||||
formMetadata: r,
|
||||
});
|
||||
}
|
||||
submitEventHandler(e) {
|
||||
const t = this.jsController.getMetadataForForm(e);
|
||||
e.setUserInfo(t);
|
||||
}
|
||||
}
|
||||
class AutoFillButtonManager {
|
||||
jsController;
|
||||
constructor(e) {
|
||||
this.jsController = e;
|
||||
}
|
||||
addEventListeners() {
|
||||
formMetadataEventDispatcher.addGlobalListener(
|
||||
"webkitautofillrequest",
|
||||
this.webKitAutofillRequestEventHandler.bind(this),
|
||||
);
|
||||
}
|
||||
webKitAutofillRequestEventHandler(e) {
|
||||
let [t, a] = this.jsController._getMetadataForControl(
|
||||
e,
|
||||
WBSFormMetadataRequestNormal,
|
||||
);
|
||||
window.webkit.messageHandlers.controller.postMessage({
|
||||
name: "manualAutoFillRequest",
|
||||
focusedElementMetadata: t,
|
||||
formMetadata: a,
|
||||
});
|
||||
}
|
||||
}
|
||||
let formMetadataJSController = new FormMetadataJSController();
|
||||
eventQueue.setDelegate(formMetadataEventDispatcher);
|
||||
0;
|
||||
43
27.0/js/forms/FormMetadataUtilities.js
Normal file
43
27.0/js/forms/FormMetadataUtilities.js
Normal file
@@ -0,0 +1,43 @@
|
||||
//# sourceURL=__InjectedScript_FormMetadataUtilities.js
|
||||
/* Copyright (c) 2026 Apple Inc. All rights reserved. */
|
||||
// Copyright (c) 2025 Apple Inc. All rights reserved.
|
||||
"use strict";
|
||||
globalThis.FormMetadataUtilitiesJS = class {
|
||||
static #t(t, e) {
|
||||
const n = /([A-Za-z0-9])/;
|
||||
let o = null,
|
||||
s = -1,
|
||||
i = -1;
|
||||
const l = t.replaceAll(".", "").toLowerCase();
|
||||
for (let t = 0; t < e.length; t++) {
|
||||
const r = e[t].replaceAll(".", "").toLowerCase(),
|
||||
a = r.indexOf(l);
|
||||
if (-1 === a) continue;
|
||||
if (a > 0 && n.test(r.charAt(a - 1))) continue;
|
||||
let c = a + l.length;
|
||||
(c < r.length && n.test(r.charAt(c))) ||
|
||||
((!o || r.length < o.length) && ((o = r), (s = t), (i = a)));
|
||||
}
|
||||
return { index: s, startPosition: i };
|
||||
}
|
||||
static bestIndexToFillSelectControl(t, e) {
|
||||
const n = t.length,
|
||||
o = [];
|
||||
for (let e = 0; e < n; e++) {
|
||||
const n = t[e][1];
|
||||
o.push(n);
|
||||
}
|
||||
let s = -1,
|
||||
i = Number.MAX_SAFE_INTEGER;
|
||||
for (let t = e.length - 1; t >= 0; t--) {
|
||||
const n = e[t];
|
||||
Number.MAX_SAFE_INTEGER;
|
||||
const l = this.#t(n, o);
|
||||
-1 !== l.index &&
|
||||
l.startPosition < i &&
|
||||
((i = l.startPosition), (s = l.index));
|
||||
}
|
||||
return -1 === s ? -1 : t[s][0];
|
||||
}
|
||||
};
|
||||
0;
|
||||
387
27.0/js/forms/PasswordRulesParserJS.js
Normal file
387
27.0/js/forms/PasswordRulesParserJS.js
Normal file
@@ -0,0 +1,387 @@
|
||||
//# sourceURL=__InjectedScript_PasswordRulesParserJS.js
|
||||
/* Copyright (c) 2026 Apple Inc. All rights reserved. */
|
||||
// Copyright (c) 2019 - 2026 Apple Inc. Licensed under MIT License.
|
||||
"use strict";
|
||||
function _isIdentifierCharacter(e) {
|
||||
return (e >= "a" && e <= "z") || (e >= "A" && e <= "Z") || "-" === e;
|
||||
}
|
||||
function _isASCIIDigit(e) {
|
||||
return e >= "0" && e <= "9";
|
||||
}
|
||||
function _isASCIIPrintableCharacter(e) {
|
||||
return e >= " " && e <= "~";
|
||||
}
|
||||
function _isASCIIWhitespace(e) {
|
||||
return " " === e || "\f" === e || "\n" === e || "\r" === e || "\t" === e;
|
||||
}
|
||||
function _bitSetIndexForCharacter(e) {
|
||||
return e.codePointAt(0) - SPACE_CODE_POINT;
|
||||
}
|
||||
function _characterAtBitSetIndex(e) {
|
||||
return String.fromCodePoint(e + SPACE_CODE_POINT);
|
||||
}
|
||||
function _markBitsForNamedCharacterClass(e, r) {
|
||||
r.name === Identifier.UPPER
|
||||
? e.fill(
|
||||
!0,
|
||||
_bitSetIndexForCharacter("A"),
|
||||
_bitSetIndexForCharacter("Z") + 1,
|
||||
)
|
||||
: r.name === Identifier.LOWER
|
||||
? e.fill(
|
||||
!0,
|
||||
_bitSetIndexForCharacter("a"),
|
||||
_bitSetIndexForCharacter("z") + 1,
|
||||
)
|
||||
: r.name === Identifier.DIGIT
|
||||
? e.fill(
|
||||
!0,
|
||||
_bitSetIndexForCharacter("0"),
|
||||
_bitSetIndexForCharacter("9") + 1,
|
||||
)
|
||||
: r.name === Identifier.SPECIAL &&
|
||||
(e.fill(
|
||||
!0,
|
||||
_bitSetIndexForCharacter(" "),
|
||||
_bitSetIndexForCharacter("/") + 1,
|
||||
),
|
||||
e.fill(
|
||||
!0,
|
||||
_bitSetIndexForCharacter(":"),
|
||||
_bitSetIndexForCharacter("@") + 1,
|
||||
),
|
||||
e.fill(
|
||||
!0,
|
||||
_bitSetIndexForCharacter("["),
|
||||
_bitSetIndexForCharacter("`") + 1,
|
||||
),
|
||||
e.fill(
|
||||
!0,
|
||||
_bitSetIndexForCharacter("{"),
|
||||
_bitSetIndexForCharacter("~") + 1,
|
||||
));
|
||||
}
|
||||
function _markBitsForCustomCharacterClass(e, r) {
|
||||
for (let t of r.characters) e[_bitSetIndexForCharacter(t)] = !0;
|
||||
}
|
||||
function _canonicalizedPropertyValues(e, r) {
|
||||
function t(e, r) {
|
||||
let t = [];
|
||||
for (
|
||||
let n = _bitSetIndexForCharacter(e);
|
||||
n <= _bitSetIndexForCharacter(r);
|
||||
++n
|
||||
)
|
||||
a[n] && t.push(_characterAtBitSetIndex(n));
|
||||
let i =
|
||||
t.length ===
|
||||
_bitSetIndexForCharacter(r) - _bitSetIndexForCharacter(e) + 1;
|
||||
return (i || (n = n.concat(t)), i);
|
||||
}
|
||||
let a = new Array("~".codePointAt(0) - " ".codePointAt(0) + 1);
|
||||
for (let r of e)
|
||||
if (r instanceof NamedCharacterClass) {
|
||||
if (r.name === Identifier.UNICODE)
|
||||
return [new NamedCharacterClass(Identifier.UNICODE)];
|
||||
if (r.name === Identifier.ASCII_PRINTABLE)
|
||||
return [new NamedCharacterClass(Identifier.ASCII_PRINTABLE)];
|
||||
_markBitsForNamedCharacterClass(a, r);
|
||||
} else
|
||||
r instanceof CustomCharacterClass &&
|
||||
_markBitsForCustomCharacterClass(a, r);
|
||||
let n = [],
|
||||
i = t("A", "Z"),
|
||||
l = t("a", "z"),
|
||||
s = t("0", "9"),
|
||||
u = !1,
|
||||
c = !1,
|
||||
o = !1,
|
||||
_ = [];
|
||||
for (
|
||||
let e = _bitSetIndexForCharacter(" ");
|
||||
e <= _bitSetIndexForCharacter("/");
|
||||
++e
|
||||
) {
|
||||
if (!a[e]) continue;
|
||||
let t = _characterAtBitSetIndex(e);
|
||||
r && "-" === t ? (c = !0) : _.push(t);
|
||||
}
|
||||
for (
|
||||
let e = _bitSetIndexForCharacter(":");
|
||||
e <= _bitSetIndexForCharacter("@");
|
||||
++e
|
||||
)
|
||||
a[e] && _.push(_characterAtBitSetIndex(e));
|
||||
for (
|
||||
let e = _bitSetIndexForCharacter("[");
|
||||
e <= _bitSetIndexForCharacter("`");
|
||||
++e
|
||||
) {
|
||||
if (!a[e]) continue;
|
||||
let t = _characterAtBitSetIndex(e);
|
||||
r && "]" === t ? (o = !0) : _.push(t);
|
||||
}
|
||||
for (
|
||||
let e = _bitSetIndexForCharacter("{");
|
||||
e <= _bitSetIndexForCharacter("~");
|
||||
++e
|
||||
)
|
||||
a[e] && _.push(_characterAtBitSetIndex(e));
|
||||
(c && _.unshift("-"), o && _.push("]"));
|
||||
let C =
|
||||
_bitSetIndexForCharacter("/") -
|
||||
_bitSetIndexForCharacter(" ") +
|
||||
1 +
|
||||
(_bitSetIndexForCharacter("@") - _bitSetIndexForCharacter(":") + 1) +
|
||||
(_bitSetIndexForCharacter("`") - _bitSetIndexForCharacter("[") + 1) +
|
||||
(_bitSetIndexForCharacter("~") - _bitSetIndexForCharacter("{") + 1);
|
||||
((u = _.length === C), u || (n = n.concat(_)));
|
||||
let h = [];
|
||||
return i && l && s && u
|
||||
? [new NamedCharacterClass(Identifier.ASCII_PRINTABLE)]
|
||||
: (i && h.push(new NamedCharacterClass(Identifier.UPPER)),
|
||||
l && h.push(new NamedCharacterClass(Identifier.LOWER)),
|
||||
s && h.push(new NamedCharacterClass(Identifier.DIGIT)),
|
||||
u && h.push(new NamedCharacterClass(Identifier.SPECIAL)),
|
||||
n.length && h.push(new CustomCharacterClass(n)),
|
||||
h);
|
||||
}
|
||||
function _indexOfNonWhitespaceCharacter(e, r = 0) {
|
||||
let t = e.length;
|
||||
for (; r < t && _isASCIIWhitespace(e[r]);) ++r;
|
||||
return r;
|
||||
}
|
||||
function _parseIdentifier(e, r) {
|
||||
let t = e.length,
|
||||
a = [];
|
||||
do {
|
||||
let t = e[r];
|
||||
if (!_isIdentifierCharacter(t)) break;
|
||||
(a.push(t), ++r);
|
||||
} while (r < t);
|
||||
return [a.join(""), r];
|
||||
}
|
||||
function _isValidRequiredOrAllowedPropertyValueIdentifier(e) {
|
||||
return e && Object.values(Identifier).includes(e.toLowerCase());
|
||||
}
|
||||
function _parseCustomCharacterClass(e, r) {
|
||||
let t = e.length;
|
||||
if (++r >= t) return [null, r];
|
||||
let a = r,
|
||||
n = [];
|
||||
do {
|
||||
let t = e[r];
|
||||
if (_isASCIIPrintableCharacter(t)) {
|
||||
if ("-" === t && r - a > 0) ++r;
|
||||
else if ((n.push(t), ++r, t === CHARACTER_CLASS_END_SENTINEL)) break;
|
||||
} else ++r;
|
||||
} while (r < t);
|
||||
if (
|
||||
(r < t && e[r] !== CHARACTER_CLASS_END_SENTINEL) ||
|
||||
(r == t && e[r - 1] == CHARACTER_CLASS_END_SENTINEL)
|
||||
) {
|
||||
if ((n.pop(), r < t)) {
|
||||
let t = e[r];
|
||||
_isASCIIWhitespace(t);
|
||||
}
|
||||
return [n, r];
|
||||
}
|
||||
return r < t && e[r] == CHARACTER_CLASS_END_SENTINEL ? [n, r + 1] : [null, r];
|
||||
}
|
||||
function _parsePasswordRequiredOrAllowedPropertyValue(e, r) {
|
||||
let t = e.length,
|
||||
a = [];
|
||||
for (;;) {
|
||||
if (_isIdentifierCharacter(e[r])) {
|
||||
let t = r;
|
||||
var [n, r] = _parseIdentifier(e, r);
|
||||
if (!_isValidRequiredOrAllowedPropertyValueIdentifier(n))
|
||||
return [null, t];
|
||||
a.push(new NamedCharacterClass(n));
|
||||
} else {
|
||||
if (e[r] != CHARACTER_CLASS_START_SENTINEL) return [null, r];
|
||||
var [n, r] = _parseCustomCharacterClass(e, r);
|
||||
n && n.length && a.push(new CustomCharacterClass(n));
|
||||
}
|
||||
if (
|
||||
(r = _indexOfNonWhitespaceCharacter(e, r)) >= t ||
|
||||
e[r] === PROPERTY_SEPARATOR
|
||||
)
|
||||
break;
|
||||
if (e[r] !== PROPERTY_VALUE_SEPARATOR) return [null, r];
|
||||
if ((r = _indexOfNonWhitespaceCharacter(e, r + 1)) >= t) return [null, r];
|
||||
}
|
||||
return [a, r];
|
||||
}
|
||||
function _parsePasswordRule(e, r) {
|
||||
let t = e.length;
|
||||
var a = r,
|
||||
[n, r] = _parseIdentifier(e, r);
|
||||
if (!Object.values(RuleName).includes(n)) return [null, a];
|
||||
if (r >= t) return [null, r];
|
||||
if (e[r] !== PROPERTY_VALUE_START_SENTINEL) return [null, r];
|
||||
let i = { name: n, value: null };
|
||||
if (
|
||||
(r = _indexOfNonWhitespaceCharacter(e, r + 1)) >= t ||
|
||||
e[r] === PROPERTY_SEPARATOR
|
||||
)
|
||||
return [new Rule(i.name, i.value), r];
|
||||
switch (n) {
|
||||
case RuleName.ALLOWED:
|
||||
case RuleName.REQUIRED:
|
||||
var [l, r] = _parsePasswordRequiredOrAllowedPropertyValue(e, r);
|
||||
return (l && (i.value = l), [new Rule(i.name, i.value), r]);
|
||||
case RuleName.MAX_CONSECUTIVE:
|
||||
var [l, r] = _parseMaxConsecutivePropertyValue(e, r);
|
||||
return (l && (i.value = l), [new Rule(i.name, i.value), r]);
|
||||
case RuleName.MIN_LENGTH:
|
||||
case RuleName.MAX_LENGTH:
|
||||
var [l, r] = _parseMinLengthMaxLengthPropertyValue(e, r);
|
||||
return (l && (i.value = l), [new Rule(i.name, i.value), r]);
|
||||
}
|
||||
}
|
||||
function _parseMinLengthMaxLengthPropertyValue(e, r) {
|
||||
return _parseInteger(e, r);
|
||||
}
|
||||
function _parseMaxConsecutivePropertyValue(e, r) {
|
||||
return _parseInteger(e, r);
|
||||
}
|
||||
function _parseInteger(e, r) {
|
||||
if (!_isASCIIDigit(e[r])) return [null, r];
|
||||
let t = e.length,
|
||||
a = 0;
|
||||
do {
|
||||
((a = 10 * a + parseInt(e[r], 10)), ++r);
|
||||
} while (r < t && e[r] !== PROPERTY_SEPARATOR && _isASCIIDigit(e[r]));
|
||||
return r >= t || e[r] === PROPERTY_SEPARATOR ? [a, r] : [null, r];
|
||||
}
|
||||
function _parsePasswordRulesInternal(e) {
|
||||
let r = [],
|
||||
t = e.length;
|
||||
for (var a = _indexOfNonWhitespaceCharacter(e); a < t;) {
|
||||
if (!_isIdentifierCharacter(e[a])) return r;
|
||||
var [n, a] = _parsePasswordRule(e, a);
|
||||
if (
|
||||
(n && n.value && r.push(n),
|
||||
(a = _indexOfNonWhitespaceCharacter(e, a)) >= t)
|
||||
)
|
||||
break;
|
||||
if (e[a] !== PROPERTY_SEPARATOR) return null;
|
||||
if ((a = _indexOfNonWhitespaceCharacter(e, a + 1)) >= t) return r;
|
||||
}
|
||||
return r;
|
||||
}
|
||||
function parsePasswordRules(e, r) {
|
||||
let t = _parsePasswordRulesInternal(e) || [],
|
||||
a = r,
|
||||
n = [],
|
||||
i = [],
|
||||
l = null,
|
||||
s = 0,
|
||||
u = null;
|
||||
for (let e of t)
|
||||
switch (e.name) {
|
||||
case RuleName.MAX_CONSECUTIVE:
|
||||
l = l ? Math.min(e.value, l) : e.value;
|
||||
break;
|
||||
case RuleName.MIN_LENGTH:
|
||||
s = Math.max(e.value, s);
|
||||
break;
|
||||
case RuleName.MAX_LENGTH:
|
||||
u = u ? Math.min(e.value, u) : e.value;
|
||||
break;
|
||||
case RuleName.REQUIRED:
|
||||
((e.value = _canonicalizedPropertyValues(e.value, r)),
|
||||
n.push(e),
|
||||
a || (i = i.concat(e.value)));
|
||||
break;
|
||||
case RuleName.ALLOWED:
|
||||
i = i.concat(e.value);
|
||||
}
|
||||
return (
|
||||
(i = _canonicalizedPropertyValues(i, a)),
|
||||
a ||
|
||||
i.length ||
|
||||
(i = [new NamedCharacterClass(Identifier.ASCII_PRINTABLE)]),
|
||||
i.length && n.push(new Rule(RuleName.ALLOWED, i)),
|
||||
null !== l && n.push(new Rule(RuleName.MAX_CONSECUTIVE, l)),
|
||||
s > 0 && n.push(new Rule(RuleName.MIN_LENGTH, s)),
|
||||
null !== u && n.push(new Rule(RuleName.MAX_LENGTH, u)),
|
||||
n
|
||||
);
|
||||
}
|
||||
console ||
|
||||
(console = {
|
||||
assert: function () {},
|
||||
error: function () {},
|
||||
warn: function () {},
|
||||
});
|
||||
const Identifier = {
|
||||
ASCII_PRINTABLE: "ascii-printable",
|
||||
DIGIT: "digit",
|
||||
LOWER: "lower",
|
||||
SPECIAL: "special",
|
||||
UNICODE: "unicode",
|
||||
UPPER: "upper",
|
||||
},
|
||||
RuleName = {
|
||||
ALLOWED: "allowed",
|
||||
MAX_CONSECUTIVE: "max-consecutive",
|
||||
REQUIRED: "required",
|
||||
MIN_LENGTH: "minlength",
|
||||
MAX_LENGTH: "maxlength",
|
||||
},
|
||||
HTMLEntity = {
|
||||
"&": "&",
|
||||
"<": "<",
|
||||
">": ">",
|
||||
'"': """,
|
||||
"'": "'",
|
||||
},
|
||||
CHARACTER_CLASS_START_SENTINEL = "[",
|
||||
CHARACTER_CLASS_END_SENTINEL = "]",
|
||||
PROPERTY_VALUE_SEPARATOR = ",",
|
||||
PROPERTY_SEPARATOR = ";",
|
||||
PROPERTY_VALUE_START_SENTINEL = ":",
|
||||
SPACE_CODE_POINT = " ".codePointAt(0),
|
||||
SHOULD_NOT_BE_REACHED = "Should not be reached";
|
||||
class Rule {
|
||||
constructor(e, r) {
|
||||
((this._name = e), (this.value = r));
|
||||
}
|
||||
get name() {
|
||||
return this._name;
|
||||
}
|
||||
toString() {
|
||||
return JSON.stringify(this);
|
||||
}
|
||||
}
|
||||
class NamedCharacterClass {
|
||||
constructor(e) {
|
||||
this._name = e;
|
||||
}
|
||||
get name() {
|
||||
return this._name.toLowerCase();
|
||||
}
|
||||
toString() {
|
||||
return this._name;
|
||||
}
|
||||
toHTMLString() {
|
||||
return this._name;
|
||||
}
|
||||
}
|
||||
class CustomCharacterClass {
|
||||
constructor(e) {
|
||||
this._characters = e;
|
||||
}
|
||||
get characters() {
|
||||
return this._characters;
|
||||
}
|
||||
toString() {
|
||||
return `[${this._characters.join("")}]`;
|
||||
}
|
||||
toHTMLString() {
|
||||
return `[${this._characters.join("").replace(/[&<>"']/g, (e) => HTMLEntity[e])}]`;
|
||||
}
|
||||
}
|
||||
0;
|
||||
152
27.0/js/forms/PatternRegexpToPasswordRulesConverter.js
Normal file
152
27.0/js/forms/PatternRegexpToPasswordRulesConverter.js
Normal file
@@ -0,0 +1,152 @@
|
||||
//# sourceURL=__InjectedScript_PatternRegexpToPasswordRulesConverter.js
|
||||
/* Copyright (c) 2026 Apple Inc. All rights reserved. */
|
||||
// Copyright (c) 2026 Apple Inc. Licensed under MIT License.
|
||||
"use strict";
|
||||
class PatternRegexpToPasswordRulesConverter {
|
||||
static convert(t) {
|
||||
try {
|
||||
return this.#t(t);
|
||||
} catch (t) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
static #t(t) {
|
||||
const e = this.#e(t),
|
||||
r = this.#r(e);
|
||||
if (r) return r;
|
||||
let s = e;
|
||||
const a = this.#s(s);
|
||||
if (((s = this.#a(s)), !this.#n(a))) return null;
|
||||
const n = s.match(/^\.[\*\+]?(?:\{(\d+),(\d*)\})?$/);
|
||||
if (n) {
|
||||
const t = this.#l(a),
|
||||
{ min: e, max: r } = this.#i(n, 1, 2);
|
||||
return this.#c(t, null, e, r);
|
||||
}
|
||||
const l = s.match(/^\[((?:[^\]\\]|\\.)*)\](?:\{(\d+),(\d*)\})?$/);
|
||||
if (!l) return null;
|
||||
const i = this.#l(a),
|
||||
c = this.#o(l, i),
|
||||
{ min: o, max: u } = this.#i(l, 2, 3);
|
||||
return this.#c(i, c, o, u);
|
||||
}
|
||||
static #e(t) {
|
||||
let e = t.trim();
|
||||
return (
|
||||
e.startsWith("^") && (e = e.substring(1)),
|
||||
e.endsWith("$") &&
|
||||
!e.endsWith("\\$") &&
|
||||
(e = e.substring(0, e.length - 1)),
|
||||
e
|
||||
);
|
||||
}
|
||||
static #r(t) {
|
||||
return "\\d*" === t || "\\d+" === t || "[0-9]*" === t || "[0-9]+" === t
|
||||
? "required: digit;"
|
||||
: "[a-z]*" === t || "[a-z]+" === t
|
||||
? "required: lower;"
|
||||
: "[A-Z]*" === t || "[A-Z]+" === t
|
||||
? "required: upper;"
|
||||
: null;
|
||||
}
|
||||
static #s(t) {
|
||||
const e = [],
|
||||
r = /\(\?=\.\*(?:\[((?:[^\]\\]|\\.)*)\]|(\\[dDwWsS]))\)/g;
|
||||
let s;
|
||||
for (; (s = r.exec(t));)
|
||||
void 0 !== s[1] ? e.push(s[1]) : e.push(this.#u(s[2]));
|
||||
return e;
|
||||
}
|
||||
static #n(t) {
|
||||
for (const e of t)
|
||||
for (const t of ["(?", "|", "\\D", "\\W", "\\S", "\\s"])
|
||||
if (e.includes(t)) return !1;
|
||||
return !0;
|
||||
}
|
||||
static #l(t) {
|
||||
const e = [];
|
||||
for (let r of t) {
|
||||
((r = r.replace(/\\d/g, "0-9")), (r = r.replace(/\\w/g, "a-zA-Z0-9_")));
|
||||
const t = [];
|
||||
let s = r;
|
||||
(s.includes("0-9") && (t.push("digit"), (s = s.replace(/0-9/g, ""))),
|
||||
s.includes("A-Z") && (t.push("upper"), (s = s.replace(/A-Z/g, ""))),
|
||||
s.includes("a-z") && (t.push("lower"), (s = s.replace(/a-z/g, ""))),
|
||||
(s = s.replace(/[a-zA-Z0-9]/g, "")),
|
||||
t.length > 0 && 0 === s.length
|
||||
? e.push(t.join(", "))
|
||||
: 0 === t.length && s.length > 0
|
||||
? e.push(this.#h(s))
|
||||
: t.length > 0 &&
|
||||
s.length > 0 &&
|
||||
(t.push(this.#h(s)), e.push(t.join(", "))));
|
||||
}
|
||||
return e;
|
||||
}
|
||||
static #u(t) {
|
||||
return { "\\d": "0-9", "\\w": "a-zA-Z0-9_" }[t] || t;
|
||||
}
|
||||
static #a(t) {
|
||||
let e = t.replace(/\(\?=\.\*\[((?:[^\]\\]|\\.)*)\]\)/g, "");
|
||||
return ((e = e.replace(/\(\?=\.\*(\\[dDwWsS])\)/g, "")), e);
|
||||
}
|
||||
static #h(t) {
|
||||
let e = t.replace(/\\\]/g, "]").split(""),
|
||||
r = !1,
|
||||
s = !1,
|
||||
a = [];
|
||||
for (const t of e) "-" === t ? (r = !0) : "]" === t ? (s = !0) : a.push(t);
|
||||
let n = "";
|
||||
return (r && (n += "-"), (n += a.join("")), s && (n += "]"), `[${n}]`);
|
||||
}
|
||||
static #o(t, e) {
|
||||
let r = t[1];
|
||||
const s = [];
|
||||
((r = r.replace(/\\d/g, "0-9")), (r = r.replace(/\\w/g, "a-zA-Z0-9_")));
|
||||
const a = (t) => e.some((e) => e === t || e.split(", ").includes(t));
|
||||
(r.includes("a-z") && !a("lower") && s.push("lower"),
|
||||
r.includes("A-Z") && !a("upper") && s.push("upper"),
|
||||
r.includes("0-9") && !a("digit") && s.push("digit"));
|
||||
let n = r;
|
||||
if (
|
||||
((n = n.replace(/a-z/g, "")),
|
||||
(n = n.replace(/A-Z/g, "")),
|
||||
(n = n.replace(/0-9/g, "")),
|
||||
(n = n.replace(/[a-zA-Z0-9]/g, "")),
|
||||
(n = n.replace(/\\(.)/g, "$1")),
|
||||
n)
|
||||
) {
|
||||
const t = this.#h(n),
|
||||
r = (t) => {
|
||||
const e = t.match(/^\[(.*)\]$/);
|
||||
return e ? "[" + [...e[1]].sort().join("") + "]" : t;
|
||||
};
|
||||
e.some((e) => r(e) === r(t)) || s.push(t);
|
||||
}
|
||||
return s.length ? s.join(", ") : null;
|
||||
}
|
||||
static #i(t, e, r) {
|
||||
let s = null,
|
||||
a = null;
|
||||
if (t[e]) {
|
||||
const r = parseInt(t[e], 10);
|
||||
isNaN(r) || (s = r);
|
||||
}
|
||||
if (t[r]) {
|
||||
const e = parseInt(t[r], 10);
|
||||
isNaN(e) || (a = e);
|
||||
}
|
||||
return { min: s, max: a };
|
||||
}
|
||||
static #c(t, e, r, s) {
|
||||
const a = [];
|
||||
for (const e of t) a.push(`required: ${e}`);
|
||||
return (
|
||||
e && a.push(`allowed: ${e}`),
|
||||
null !== r && a.push(`minlength: ${r}`),
|
||||
null !== s && a.push(`maxlength: ${s}`),
|
||||
a.join("; ") + ";"
|
||||
);
|
||||
}
|
||||
}
|
||||
0;
|
||||
71
27.0/js/layout/WebContentLayoutAnalyzer.js
Normal file
71
27.0/js/layout/WebContentLayoutAnalyzer.js
Normal file
@@ -0,0 +1,71 @@
|
||||
//# sourceURL=__InjectedScript_WebContentLayoutAnalyzer.js
|
||||
/* Copyright (c) 2026 Apple Inc. All rights reserved. */
|
||||
// Copyright (c) 2013 Apple Inc. All rights reserved.
|
||||
function elementAppearsCentered(e, t) {
|
||||
var n = window.innerWidth - t.right - t.left;
|
||||
return Math.abs(n) <= 1;
|
||||
}
|
||||
function centeredElementIsNotAContainer(e, t) {
|
||||
if (e === document.documentElement || e === document.body) return !0;
|
||||
if (0 === t.left && t.width === window.innerWidth) return !0;
|
||||
if (!t.height) return !0;
|
||||
var n = e.innerText;
|
||||
return !n || !n.trim();
|
||||
}
|
||||
var WebContentLayoutAnalyzer = function () {
|
||||
((this.centeredContainerElement = null),
|
||||
(this.rectOfCenteredContainerElementBeforeResize = null),
|
||||
(this.rectOfCenteredContainerElementAfterResize = null));
|
||||
};
|
||||
WebContentLayoutAnalyzer.prototype = {
|
||||
findCenteredContainerElement: function () {
|
||||
for (
|
||||
var e = null,
|
||||
t = null,
|
||||
n = document.getElementsByTagName("*"),
|
||||
r = n.length,
|
||||
i = 0;
|
||||
i < r;
|
||||
++i
|
||||
) {
|
||||
var o = n[i],
|
||||
l = o.getBoundingClientRect();
|
||||
elementAppearsCentered(o, l) &&
|
||||
(centeredElementIsNotAContainer(o, l) ||
|
||||
((!t || l.width > t.width) && ((e = o), (t = l))));
|
||||
}
|
||||
return e;
|
||||
},
|
||||
collectInformationBeforeResize: function () {
|
||||
((this.centeredContainerElement = this.findCenteredContainerElement()),
|
||||
this.centeredContainerElement &&
|
||||
(this.rectOfCenteredContainerElementBeforeResize =
|
||||
this.centeredContainerElement.getBoundingClientRect()));
|
||||
},
|
||||
collectInformationAfterResize: function () {
|
||||
this.centeredContainerElement &&
|
||||
document.contains(this.centeredContainerElement) &&
|
||||
(this.rectOfCenteredContainerElementAfterResize =
|
||||
this.centeredContainerElement.getBoundingClientRect());
|
||||
},
|
||||
layoutInformation: function () {
|
||||
var e = !1,
|
||||
t = null;
|
||||
return (
|
||||
this.rectOfCenteredContainerElementBeforeResize &&
|
||||
this.rectOfCenteredContainerElementAfterResize &&
|
||||
((e =
|
||||
this.rectOfCenteredContainerElementBeforeResize.width ===
|
||||
this.rectOfCenteredContainerElementAfterResize.width),
|
||||
(t =
|
||||
this.rectOfCenteredContainerElementBeforeResize.left -
|
||||
this.rectOfCenteredContainerElementAfterResize.left)),
|
||||
{
|
||||
FoundCenteredContainer: !!this.centeredContainerElement,
|
||||
CenteredContainerIsFixedWidth: e,
|
||||
DistanceContainerMoved: t,
|
||||
}
|
||||
);
|
||||
},
|
||||
};
|
||||
var WebContentLayoutAnalyzerJS = new WebContentLayoutAnalyzer();
|
||||
109
27.0/js/media/CNNCaptionQuirk.js
Normal file
109
27.0/js/media/CNNCaptionQuirk.js
Normal file
@@ -0,0 +1,109 @@
|
||||
//# sourceURL=__InjectedScript_CNNCaptionQuirk.js
|
||||
(function () {
|
||||
"use strict";
|
||||
|
||||
class CaptionMirror {
|
||||
static _instances = new WeakMap();
|
||||
constructor(video) {
|
||||
let oldMirror = CaptionMirror._instances.get(video);
|
||||
if (oldMirror) {
|
||||
oldMirror.invalidate();
|
||||
CaptionMirror._instances.delete(video);
|
||||
}
|
||||
CaptionMirror._instances.set(video, this);
|
||||
this._video = video;
|
||||
this._playerSelector = '[data-component-name="video-player"]';
|
||||
this._overlayRootSelector = '[data-testid="overlay-root"]';
|
||||
this._captionRowSelector = '[data-testid="cueBoxRowTextCue"]';
|
||||
this._player = this._findPlayerRoot(video);
|
||||
this._mirrorTrack = video.addTextTrack("forced", "CNN Captions");
|
||||
this._mirrorTrack.mode = "hidden";
|
||||
this._captionObserver = null;
|
||||
this._waitObserver = null;
|
||||
this._onPresentationModeChanged = () =>
|
||||
this._handlePresentationModeChanged();
|
||||
this._video.addEventListener(
|
||||
"webkitpresentationmodechanged",
|
||||
this._onPresentationModeChanged,
|
||||
);
|
||||
if (this._player) this._attachOverlayObserver();
|
||||
}
|
||||
invalidate() {
|
||||
if (this._captionObserver) {
|
||||
this._captionObserver.disconnect();
|
||||
this._captionObserver = null;
|
||||
}
|
||||
if (this._waitObserver) {
|
||||
this._waitObserver.disconnect();
|
||||
this._waitObserver = null;
|
||||
}
|
||||
this._mirrorTrack.mode = "disabled";
|
||||
this._video.removeEventListener(
|
||||
"webkitpresentationmodechanged",
|
||||
this._onPresentationModeChanged,
|
||||
);
|
||||
}
|
||||
_findPlayerRoot(video) {
|
||||
return video.closest(this._playerSelector);
|
||||
}
|
||||
_syncCues(overlayRoot) {
|
||||
while (this._mirrorTrack.cues?.length)
|
||||
this._mirrorTrack.removeCue(this._mirrorTrack.cues[0]);
|
||||
var rows = Array.from(
|
||||
overlayRoot.querySelectorAll(this._captionRowSelector),
|
||||
);
|
||||
if (!rows.length) return;
|
||||
var text = rows.map((row) => row.textContent).join("\n");
|
||||
if (!text) return;
|
||||
var cue = new VTTCue(0, 10e7, text);
|
||||
cue.snapToLines = true;
|
||||
cue.line = -4;
|
||||
cue.position = "auto";
|
||||
cue.positionAlign = "center";
|
||||
this._mirrorTrack.addCue(cue);
|
||||
}
|
||||
|
||||
_attachOverlayObserver() {
|
||||
var overlayRoot = this._player.querySelector(this._overlayRootSelector);
|
||||
if (overlayRoot) {
|
||||
this._attachCaptionObserver(overlayRoot);
|
||||
return;
|
||||
}
|
||||
this._waitObserver = new MutationObserver(() => {
|
||||
var overlayRoot = this._player.querySelector(this._overlayRootSelector);
|
||||
if (overlayRoot) {
|
||||
this._attachCaptionObserver(overlayRoot);
|
||||
this._waitObserver.disconnect();
|
||||
this._waitObserver = null;
|
||||
}
|
||||
});
|
||||
this._waitObserver.observe(this._player, {
|
||||
childList: true,
|
||||
subtree: true,
|
||||
});
|
||||
}
|
||||
_attachCaptionObserver(overlayRoot) {
|
||||
if (this._captionObserver) this._captionObserver.disconnect();
|
||||
this._captionObserver = new MutationObserver(() => {
|
||||
var current = this._player.querySelector(this._overlayRootSelector);
|
||||
if (current) this._syncCues(current);
|
||||
});
|
||||
this._captionObserver.observe(overlayRoot, {
|
||||
childList: true,
|
||||
subtree: true,
|
||||
characterData: true,
|
||||
});
|
||||
this._syncCues(overlayRoot);
|
||||
}
|
||||
_handlePresentationModeChanged() {
|
||||
if (this._video.webkitPresentationMode == "inline") {
|
||||
this._mirrorTrack.mode = "hidden";
|
||||
return;
|
||||
}
|
||||
this._mirrorTrack.mode = "showing";
|
||||
}
|
||||
}
|
||||
window.setupCaptionMirroring = function (video) {
|
||||
new CaptionMirror(video);
|
||||
};
|
||||
})();
|
||||
5349
27.0/js/media/ModernMediaControls.js
Normal file
5349
27.0/js/media/ModernMediaControls.js
Normal file
File diff suppressed because it is too large
Load Diff
202
27.0/js/media/YouTubeCaptionQuirk.js
Normal file
202
27.0/js/media/YouTubeCaptionQuirk.js
Normal file
@@ -0,0 +1,202 @@
|
||||
//# sourceURL=__InjectedScript_YouTubeCaptionQuirk.js
|
||||
(function () {
|
||||
"use strict";
|
||||
class CaptionMirror {
|
||||
static _instances = new WeakMap();
|
||||
constructor(video) {
|
||||
let oldMirror = CaptionMirror._instances.get(video);
|
||||
if (oldMirror) {
|
||||
oldMirror.invalidate();
|
||||
CaptionMirror._instances.delete(video);
|
||||
}
|
||||
CaptionMirror._instances.set(video, this);
|
||||
this._video = video;
|
||||
this._player = video.parentElement.parentElement;
|
||||
this._captionWindowSelector = ".ytp-caption-window-container";
|
||||
this._mirrorTrack = video.addTextTrack("forced", "YouTube Captions");
|
||||
this._mirrorTrack.mode = "hidden";
|
||||
this._captionObserver = null;
|
||||
this._waitObserver = null;
|
||||
this._onCaptionsTrackListChanged = () => this._syncTrackList();
|
||||
this._onCaptionsChanged = () => this._syncTrackList();
|
||||
this._player.addEventListener(
|
||||
"onCaptionsTrackListChanged",
|
||||
this._onCaptionsTrackListChanged,
|
||||
);
|
||||
this._player.addEventListener("captionschanged", this._onCaptionsChanged);
|
||||
navigator.mediaSession.setActionHandler("togglecaptions", (details) =>
|
||||
this._handleMediaSessionAction(details),
|
||||
);
|
||||
navigator.mediaSession.setActionHandler("selectcaptiontrack", (details) =>
|
||||
this._handleMediaSessionAction(details),
|
||||
);
|
||||
this._onPresentationModeChanged = () =>
|
||||
this._handlePresentationModeChanged();
|
||||
this._video.addEventListener(
|
||||
"webkitpresentationmodechanged",
|
||||
this._onPresentationModeChanged,
|
||||
);
|
||||
this._attachCaptionWindowObserver();
|
||||
this._syncTrackList();
|
||||
}
|
||||
invalidate() {
|
||||
if (this._captionObserver) {
|
||||
this._captionObserver.disconnect();
|
||||
this._captionObserver = null;
|
||||
}
|
||||
if (this._waitObserver) {
|
||||
this._waitObserver.disconnect();
|
||||
this._waitObserver = null;
|
||||
}
|
||||
this._mirrorTrack.mode = "disabled";
|
||||
this._player.removeEventListener(
|
||||
"onCaptionsTrackListChanged",
|
||||
this._onCaptionsTrackListChanged,
|
||||
);
|
||||
this._player.removeEventListener(
|
||||
"captionschanged",
|
||||
this._onCaptionsChanged,
|
||||
);
|
||||
this._video.removeEventListener(
|
||||
"webkitpresentationmodechanged",
|
||||
this._onPresentationModeChanged,
|
||||
);
|
||||
}
|
||||
_syncTrackList() {
|
||||
var trackList = this._getTrackList();
|
||||
var activeTrack = this._getActiveTrack();
|
||||
navigator.mediaSession.captionTracks =
|
||||
trackList?.map((track) => {
|
||||
return {
|
||||
label: track.displayName,
|
||||
language: track.languageCode,
|
||||
enabled: this._areTracksEqual(track, activeTrack),
|
||||
};
|
||||
}) ?? [];
|
||||
navigator.mediaSession.captionsEnabled = this._player.isSubtitlesOn();
|
||||
}
|
||||
_syncCues(captionWindowContainer) {
|
||||
while (this._mirrorTrack.cues?.length)
|
||||
this._mirrorTrack.removeCue(this._mirrorTrack.cues[0]);
|
||||
for (var captionWindow of captionWindowContainer.querySelectorAll(
|
||||
".caption-window",
|
||||
)) {
|
||||
var text = Array.from(
|
||||
captionWindow.querySelectorAll(".captions-text > span"),
|
||||
)
|
||||
.map((span) => span.textContent)
|
||||
.join("\n");
|
||||
if (!text) continue;
|
||||
var cue = new VTTCue(0, 10e7, text);
|
||||
switch (captionWindow.style.textAlign) {
|
||||
case "left":
|
||||
case "start":
|
||||
cue.align = "start";
|
||||
cue.positionAlign = "line-left";
|
||||
break;
|
||||
case "end":
|
||||
case "right":
|
||||
cue.align = "end";
|
||||
cue.positionAlign = "line-right";
|
||||
break;
|
||||
default:
|
||||
cue.align = "center";
|
||||
cue.positionAlign = "center";
|
||||
}
|
||||
var topPercent = parseFloat(captionWindow.style.top);
|
||||
var bottomPercent = parseFloat(captionWindow.style.bottom);
|
||||
var leftPercent = parseFloat(captionWindow.style.left);
|
||||
var rightPercent = parseFloat(captionWindow.style.right);
|
||||
if (!isNaN(topPercent)) {
|
||||
cue.snapToLines = false;
|
||||
cue.line = topPercent;
|
||||
} else if (!isNaN(bottomPercent)) {
|
||||
cue.snapToLines = false;
|
||||
cue.line = 100 - bottomPercent;
|
||||
}
|
||||
if (!isNaN(leftPercent)) cue.position = leftPercent;
|
||||
else if (!isNaN(rightPercent)) cue.position = 100 - rightPercent;
|
||||
this._mirrorTrack.addCue(cue);
|
||||
}
|
||||
}
|
||||
_attachCaptionWindowObserver() {
|
||||
var container = this._player.querySelector(this._captionWindowSelector);
|
||||
if (container) this._attachCaptionObserver(container);
|
||||
else {
|
||||
this._waitObserver = new MutationObserver(() => {
|
||||
var container = this._player.querySelector(
|
||||
this._captionWindowSelector,
|
||||
);
|
||||
if (container) {
|
||||
this._attachCaptionObserver(container);
|
||||
this._waitObserver.disconnect();
|
||||
this._waitObserver = null;
|
||||
}
|
||||
});
|
||||
this._waitObserver.observe(this._player, {
|
||||
childList: true,
|
||||
subtree: true,
|
||||
});
|
||||
}
|
||||
}
|
||||
_attachCaptionObserver(container) {
|
||||
if (this._captionObserver) this._captionObserver.disconnect();
|
||||
this._captionObserver = new MutationObserver(() => {
|
||||
var container = this._player.querySelector(this._captionWindowSelector);
|
||||
if (container) this._syncCues(container);
|
||||
});
|
||||
this._captionObserver.observe(container, {
|
||||
childList: true,
|
||||
subtree: true,
|
||||
characterData: true,
|
||||
});
|
||||
}
|
||||
_getIsInline() {
|
||||
if (typeof this._video.webkitPresentationMode === "undefined")
|
||||
return !this._video.webkitDisplayingFullscreen;
|
||||
return this._video.webkitPresentationMode == "inline";
|
||||
}
|
||||
_handlePresentationModeChanged() {
|
||||
var captionContainer = this._player.querySelector(
|
||||
this._captionWindowSelector,
|
||||
);
|
||||
if (this._getIsInline()) {
|
||||
this._mirrorTrack.mode = "hidden";
|
||||
if (captionContainer)
|
||||
captionContainer.style.removeProperty("visibility");
|
||||
return;
|
||||
}
|
||||
this._player.loadModule("captions");
|
||||
this._mirrorTrack.mode = "showing";
|
||||
if (captionContainer)
|
||||
captionContainer.style.setProperty("visibility", "hidden", "important");
|
||||
}
|
||||
_handleMediaSessionAction(details) {
|
||||
switch (details.action) {
|
||||
case "togglecaptions":
|
||||
this._player.toggleSubtitles();
|
||||
break;
|
||||
case "selectcaptiontrack": {
|
||||
var list = this._getTrackList();
|
||||
var index = details.trackIndex;
|
||||
if (index >= 0 && index < list.length)
|
||||
this._player.setOption("captions", "track", list[index]);
|
||||
else this._player.setOption("captions", "track", {});
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
_getTrackList() {
|
||||
return this._player.getOption("captions", "tracklist") || [];
|
||||
}
|
||||
_getActiveTrack() {
|
||||
return this._player.getOption("captions", "track");
|
||||
}
|
||||
_areTracksEqual(a, b) {
|
||||
return a && b && a.vss_id === b.vss_id;
|
||||
}
|
||||
}
|
||||
window.setupCaptionMirroring = function (video) {
|
||||
new CaptionMirror(video);
|
||||
};
|
||||
})();
|
||||
105
27.0/js/metadata/MetadataExtractor.js
Normal file
105
27.0/js/metadata/MetadataExtractor.js
Normal file
@@ -0,0 +1,105 @@
|
||||
//# sourceURL=__InjectedScript_MetadataExtractor.js
|
||||
/* Copyright (c) 2026 Apple Inc. All rights reserved. */
|
||||
function getIconType(e) {
|
||||
var o = e.getAttribute("rel");
|
||||
return "apple-touch-icon" === o
|
||||
? IconTypeAppleTouchIcon
|
||||
: "apple-touch-icon-precomposed" === o
|
||||
? IconTypeAppleTouchIconPrecomposed
|
||||
: IconTypeFavicon;
|
||||
}
|
||||
function compareIconsDescending(e, o) {
|
||||
var c = getIconType(e),
|
||||
t = getIconType(o);
|
||||
if (c === IconTypeFavicon && t !== IconTypeFavicon) return 1;
|
||||
if (t === IconTypeFavicon && c !== IconTypeFavicon) return -1;
|
||||
var n = e.getAttribute("sizes"),
|
||||
r = o.getAttribute("sizes"),
|
||||
p = 0,
|
||||
a = 0;
|
||||
return (
|
||||
n
|
||||
? (p = parseInt(n))
|
||||
: n ||
|
||||
(c !== IconTypeAppleTouchIcon &&
|
||||
c !== IconTypeAppleTouchIconPrecomposed) ||
|
||||
(p = AppleTouchIconDefaultWidth),
|
||||
r
|
||||
? (a = parseInt(r))
|
||||
: r ||
|
||||
(t !== IconTypeAppleTouchIcon &&
|
||||
t !== IconTypeAppleTouchIconPrecomposed) ||
|
||||
(a = AppleTouchIconDefaultWidth),
|
||||
a > p
|
||||
? 1
|
||||
: a < p
|
||||
? -1
|
||||
: c !== IconTypeAppleTouchIconPrecomposed &&
|
||||
t === IconTypeAppleTouchIconPrecomposed
|
||||
? 1
|
||||
: t !== IconTypeAppleTouchIconPrecomposed &&
|
||||
c === IconTypeAppleTouchIconPrecomposed
|
||||
? -1
|
||||
: 0
|
||||
);
|
||||
}
|
||||
function colorComponentsFromString(e) {
|
||||
var o = document.createElement("canvas");
|
||||
((o.width = 1), (o.height = 1));
|
||||
var c = o.getContext("2d");
|
||||
((c.fillStyle = e), c.fillRect(0, 0, 1, 1));
|
||||
var t = c.getImageData(0, 0, 1, 1);
|
||||
return [t.data[0], t.data[1], t.data[2]];
|
||||
}
|
||||
var MetadataExtractor = function () {};
|
||||
const IconTypeFavicon = 0,
|
||||
IconTypeAppleTouchIcon = 1,
|
||||
IconTypeAppleTouchIconPrecomposed = 2,
|
||||
AppleTouchIconDefaultWidth = 60;
|
||||
MetadataExtractor.prototype = {
|
||||
extractAndSortIconsWithSelector: function (e) {
|
||||
var o = document.head.querySelectorAll(e);
|
||||
return o.length
|
||||
? Array.prototype.slice.call(o).sort(compareIconsDescending)
|
||||
: [];
|
||||
},
|
||||
extractAppleTouchIconURLs: function () {
|
||||
for (
|
||||
var e = this.extractAndSortIconsWithSelector(
|
||||
"link[rel=apple-touch-icon], link[rel=apple-touch-icon-precomposed]",
|
||||
),
|
||||
o = [],
|
||||
c = 0;
|
||||
c < e.length;
|
||||
++c
|
||||
) {
|
||||
var t = e[c].href;
|
||||
t && o.push(t);
|
||||
}
|
||||
return o;
|
||||
},
|
||||
extractFaviconURLs: function () {
|
||||
for (
|
||||
var e = this.extractAndSortIconsWithSelector(
|
||||
"link[rel='shortcut icon'], link[rel=icon]",
|
||||
),
|
||||
o = [],
|
||||
c = e.length,
|
||||
t = 0;
|
||||
t < c;
|
||||
++t
|
||||
)
|
||||
o.push(e[t].href);
|
||||
return o;
|
||||
},
|
||||
extractTemplateIconURLAndColor: function () {
|
||||
var e = document.head.querySelector("link[rel=mask-icon]");
|
||||
if (!e) return null;
|
||||
var o = e.getAttribute("color");
|
||||
return o && e.href
|
||||
? { url: e.href, color: colorComponentsFromString(o) }
|
||||
: null;
|
||||
},
|
||||
};
|
||||
var MetadataExtractorJS = new MetadataExtractor();
|
||||
0;
|
||||
116
27.0/js/metadata/WebClipMetadataFetcher.js
Normal file
116
27.0/js/metadata/WebClipMetadataFetcher.js
Normal file
@@ -0,0 +1,116 @@
|
||||
//# sourceURL=__InjectedScript_WebClipMetadataFetcher.js
|
||||
/* Copyright (c) 2026 Apple Inc. All rights reserved. */
|
||||
/*
|
||||
* Copyright (c) 2014 Apple Inc. All rights reserved.
|
||||
*/
|
||||
const MetaTagNamesToScrape = [
|
||||
"apple-mobile-web-app-capable",
|
||||
"apple-mobile-web-app-title",
|
||||
"viewport",
|
||||
"apple-mobile-web-app-status-bar-style",
|
||||
],
|
||||
LinkRelTypesToScrape = [
|
||||
"apple-touch-icon",
|
||||
"apple-touch-icon-precomposed",
|
||||
"apple-touch-startup-image",
|
||||
"icon",
|
||||
"shortcut icon",
|
||||
];
|
||||
var Orientation = { Portrait: 0, Landscape: 1 },
|
||||
WebClipMetadataFinder = function () {};
|
||||
WebClipMetadataFinder.prototype = {
|
||||
webClipMetadata: function () {
|
||||
return {
|
||||
metaTags: this.metaTagsMetadata(),
|
||||
linkTags: this.linkTagsMetadata(),
|
||||
canonicalURLString: this.canonicalURLStringForPage(),
|
||||
};
|
||||
},
|
||||
metaTagsMetadata: function () {
|
||||
function e(e) {
|
||||
if ("apple-mobile-web-app-status-bar-style" === e.name)
|
||||
e.content.toLowerCase();
|
||||
}
|
||||
for (
|
||||
var t = {},
|
||||
a = document.head.getElementsByTagName("meta"),
|
||||
i = a.length,
|
||||
n = 0;
|
||||
n < i;
|
||||
++n
|
||||
) {
|
||||
var r = a[n],
|
||||
o = r.name;
|
||||
-1 !== MetaTagNamesToScrape.indexOf(o) && (e(r), (t[o] = r.content));
|
||||
}
|
||||
return t;
|
||||
},
|
||||
currentOrientation: function () {
|
||||
return (
|
||||
void 0 === this._currentOrientation &&
|
||||
(window.matchMedia("(orientation: portrait)").matches
|
||||
? (this._currentOrientation = Orientation.Portrait)
|
||||
: (this._currentOrientation = Orientation.Landscape)),
|
||||
this._currentOrientation
|
||||
);
|
||||
},
|
||||
canonicalURLStringForPage: function () {
|
||||
var e = document.head.querySelector("link[rel='canonical']");
|
||||
return e ? e.href : "";
|
||||
},
|
||||
linkTagsMetadata: function () {
|
||||
for (
|
||||
var e = [],
|
||||
t = document.head.getElementsByTagName("link"),
|
||||
a = t.length,
|
||||
i = 0;
|
||||
i < a;
|
||||
++i
|
||||
) {
|
||||
var n = t[i],
|
||||
r = n.rel;
|
||||
if (-1 !== LinkRelTypesToScrape.indexOf(r)) {
|
||||
var o = n.href,
|
||||
c = n.getAttribute("sizes");
|
||||
if (o) {
|
||||
var s = n.media,
|
||||
p = !0,
|
||||
d = !0;
|
||||
if (s) {
|
||||
var u = window.matchMedia(s);
|
||||
((p = this.mediaQueryListMatchesOrientation(
|
||||
u,
|
||||
Orientation.Portrait,
|
||||
)),
|
||||
(d = this.mediaQueryListMatchesOrientation(
|
||||
u,
|
||||
Orientation.Landscape,
|
||||
)));
|
||||
}
|
||||
var l = {
|
||||
rel: r,
|
||||
href: o,
|
||||
mediaMatchesPortraitOrientation: p,
|
||||
mediaMatchesLandscapeOrientation: d,
|
||||
};
|
||||
(c && (l.sizes = c), e.push(l));
|
||||
}
|
||||
}
|
||||
}
|
||||
return e;
|
||||
},
|
||||
mediaQueryListMatchesOrientation: function (e, t) {
|
||||
var a = e.media;
|
||||
if ("invalid" === a) return !1;
|
||||
if (t === this.currentOrientation()) return e.matches;
|
||||
var i = this.reverseMediaQueryOrientation(a);
|
||||
return window.matchMedia(i).matches;
|
||||
},
|
||||
reverseMediaQueryOrientation: function (e) {
|
||||
return e.replace(/orientation: (portrait|landscape)/, function (e, t) {
|
||||
return "orientation: " + ("portrait" === t ? "landscape" : "portrait");
|
||||
});
|
||||
},
|
||||
};
|
||||
var WebClipMetadataFinderJS = new WebClipMetadataFinder();
|
||||
0;
|
||||
5108
27.0/js/reader/ReaderArticleFinder.js
Normal file
5108
27.0/js/reader/ReaderArticleFinder.js
Normal file
File diff suppressed because it is too large
Load Diff
24
27.0/js/reader/ReaderMacUI.js
Normal file
24
27.0/js/reader/ReaderMacUI.js
Normal file
@@ -0,0 +1,24 @@
|
||||
//# sourceURL=__InjectedScript_ReaderMacUI.js
|
||||
/* Copyright (c) 2026 Apple Inc. All rights reserved. */
|
||||
/*
|
||||
* Copyright (c) 2010 Apple Inc. All rights reserved.
|
||||
*/
|
||||
function setScrollTop(e) {
|
||||
document.documentElement.scrollTop = e;
|
||||
}
|
||||
function readerWillBecomeVisible() {
|
||||
setReaderIsActive(!0);
|
||||
}
|
||||
function readerWillEnterBackground() {
|
||||
setReaderIsActive(!1);
|
||||
}
|
||||
((ReaderJS._clickingOutsideOfPaperRectangleDismissesReader = !0),
|
||||
(ReaderJS._isJavaScriptEnabled = function () {
|
||||
return !!(ReaderJSController.initialConfiguration() || {})[
|
||||
ReaderConfigurationJavaScriptEnabledKey
|
||||
];
|
||||
}),
|
||||
(ReaderAppearanceJS._tryApplyStaticConfiguration = function () {
|
||||
return (document.body.classList.add("mac"), !1);
|
||||
}));
|
||||
0;
|
||||
57
27.0/js/reader/ReaderMobileUI.js
Normal file
57
27.0/js/reader/ReaderMobileUI.js
Normal file
@@ -0,0 +1,57 @@
|
||||
//# sourceURL=__InjectedScript_ReaderMobileUI.js
|
||||
/* Copyright (c) 2026 Apple Inc. All rights reserved. */
|
||||
/*
|
||||
* Copyright (c) 2010 Apple Inc. All rights reserved.
|
||||
*/
|
||||
function orientationChanged() {
|
||||
ReaderAppearanceJS.layOutContent();
|
||||
}
|
||||
function articleHasScrolled() {
|
||||
ReaderJS.resumeCachedNextPageLoadIfNecessary();
|
||||
}
|
||||
function contentInPrintingMailingFrame() {
|
||||
let e = document.getElementById(ReaderJS.printingMailingFrameElementId());
|
||||
return (
|
||||
e ||
|
||||
(ReaderJS.preparePrintingMailingFrame(),
|
||||
(e = document.getElementById(ReaderJS.printingMailingFrameElementId()))),
|
||||
e.contentDocument.documentElement.innerHTML
|
||||
);
|
||||
}
|
||||
(window.addEventListener("orientationchange", orientationChanged, !1),
|
||||
window.addEventListener("scroll", articleHasScrolled, !1));
|
||||
let originalShouldUsePaperAppearance =
|
||||
ReaderAppearanceJS._shouldUsePaperAppearance.bind(ReaderAppearanceJS);
|
||||
((ReaderAppearanceJS._shouldUsePaperAppearance = function () {
|
||||
return (
|
||||
0 !== window.orientation &&
|
||||
180 !== window.orientation &&
|
||||
originalShouldUsePaperAppearance()
|
||||
);
|
||||
}),
|
||||
(ReaderAppearanceJS._isOLEDDisplay = function () {
|
||||
return !!(ReaderJSController.initialConfiguration() || {}).isOLEDDisplay;
|
||||
}),
|
||||
(ReaderJS._distanceFromBottomOfArticleToStartLoadingNextPage = function () {
|
||||
return (
|
||||
ReaderJSController.maxDistanceForLoadingNextPage() ||
|
||||
(screen.height >= 1024 ? 2048 : 1024)
|
||||
);
|
||||
}),
|
||||
(ReaderJS._shouldSkipActivationWhenPageLoads = function () {
|
||||
return (
|
||||
ReaderJSController.isLoadingFromOfflineReadingListArchive &&
|
||||
ReaderJSController.isLoadingFromOfflineReadingListArchive()
|
||||
);
|
||||
}),
|
||||
(ReaderJS._shouldConvertRelativeURLsToAbsoluteURLsWhenPrintingOrMailing = !0),
|
||||
(ReaderJS._deferSendingContentIsReadyForDisplay = !0),
|
||||
(ReaderJS._isJavaScriptEnabled = function () {
|
||||
return !!(ReaderJSController.initialConfiguration() || {})[
|
||||
ReaderConfigurationJavaScriptEnabledKey
|
||||
];
|
||||
}),
|
||||
(ReaderAppearanceJS._tryApplyStaticConfiguration = function () {
|
||||
return (document.body.classList.add("ios"), !1);
|
||||
}));
|
||||
0;
|
||||
29
27.0/js/reader/ReaderShared.js
Normal file
29
27.0/js/reader/ReaderShared.js
Normal file
@@ -0,0 +1,29 @@
|
||||
//# sourceURL=__InjectedScript_ReaderShared.js
|
||||
/* Copyright (c) 2026 Apple Inc. All rights reserved. */
|
||||
// Copyright (c) 2025 Apple Inc. All rights reserved.
|
||||
"use strict";
|
||||
function normalizedElementTagName(e) {
|
||||
return e.localName;
|
||||
}
|
||||
function plaintextVersionOfNodeAppendingNewlinesBetweenBlockElements(e) {
|
||||
const n = (e.ownerDocument ?? document).createTreeWalker(
|
||||
e,
|
||||
NodeFilter.SHOW_ELEMENT | NodeFilter.SHOW_TEXT,
|
||||
null,
|
||||
);
|
||||
let t = "";
|
||||
for (n.currentNode = e; n.nextNode();) {
|
||||
const e = n.currentNode;
|
||||
if (e.nodeType === Node.TEXT_NODE) {
|
||||
t += e.textContent;
|
||||
continue;
|
||||
}
|
||||
let o = normalizedElementTagName(e);
|
||||
("p" !== o && "div" !== o) || (t += "\n");
|
||||
}
|
||||
return t;
|
||||
}
|
||||
const READER_UNIQUE_ID_ATTRIBUTE_KEY = "data-reader-unique-id",
|
||||
READER_UNIQUE_ID_TITLE = "titleElement",
|
||||
READER_UNIQUE_ID_SUBHEAD = "subheadElement";
|
||||
0;
|
||||
2909
27.0/js/reader/ReaderSharedUI.js
Normal file
2909
27.0/js/reader/ReaderSharedUI.js
Normal file
File diff suppressed because it is too large
Load Diff
38
27.0/js/reader/ReaderSharedUINormalWorld.js
Normal file
38
27.0/js/reader/ReaderSharedUINormalWorld.js
Normal file
@@ -0,0 +1,38 @@
|
||||
//# sourceURL=__InjectedScript_ReaderSharedUINormalWorld.js
|
||||
/* Copyright (c) 2026 Apple Inc. All rights reserved. */
|
||||
function loadTwitterJavaScript() {
|
||||
window.twttr ||
|
||||
(window.twttr = (function (e, t, r) {
|
||||
var i,
|
||||
a,
|
||||
d = e.getElementsByTagName(t)[0];
|
||||
if (!e.getElementById(r))
|
||||
return (
|
||||
((a = e.createElement(t)).id = r),
|
||||
(a.src = "https://platform.twitter.com/widgets.js"),
|
||||
d.parentNode.insertBefore(a, d),
|
||||
window.twttr ||
|
||||
(i = {
|
||||
_e: [],
|
||||
ready: function (e) {
|
||||
i._e.push(e);
|
||||
},
|
||||
})
|
||||
);
|
||||
})(document, "script", "twitter-wjs"));
|
||||
}
|
||||
function richTweetWasCreatedFromSimpleTweet(e) {
|
||||
e.parentNode.querySelector(".simple-tweet").classList.add("hidden");
|
||||
}
|
||||
function replaceSimpleTweetsWithRichTweets(e) {
|
||||
let t = document.querySelectorAll("[data-reader-tweet-id]");
|
||||
t.length &&
|
||||
(loadTwitterJavaScript(),
|
||||
twttr.ready(function (r) {
|
||||
for (let i of t)
|
||||
r.widgets
|
||||
.createTweet(i.getAttribute("data-reader-tweet-id"), i, e)
|
||||
.then(richTweetWasCreatedFromSimpleTweet);
|
||||
}));
|
||||
}
|
||||
0;
|
||||
249
27.0/js/schema/SchemaDataExtractor.js
Normal file
249
27.0/js/schema/SchemaDataExtractor.js
Normal file
@@ -0,0 +1,249 @@
|
||||
//# sourceURL=__InjectedScript_SchemaDataExtractor.js
|
||||
/* Copyright (c) 2026 Apple Inc. All rights reserved. */
|
||||
var SchemaDataExtractor = function () {};
|
||||
((SchemaDataExtractor.validAddressProperties = {
|
||||
addressCountry: 1,
|
||||
addressLocality: 1,
|
||||
addressRegion: 1,
|
||||
postOfficeBoxNumber: 1,
|
||||
postalCode: 1,
|
||||
streetAddress: 1,
|
||||
}),
|
||||
(SchemaDataExtractor.validParentSchemaTypes = {
|
||||
"http://schema.org/Person": 1,
|
||||
"https://schema.org/Person": 1,
|
||||
"http://schema.org/LocalBusiness": 1,
|
||||
"https://schema.org/LocalBusiness": 1,
|
||||
"http://schema.org/Organization": 1,
|
||||
"https://schema.org/Organization": 1,
|
||||
"http://schema.org/Restaurant": 1,
|
||||
"https://schema.org/Restaurant": 1,
|
||||
"http://schema.org/Corporation": 1,
|
||||
"https://schema.org/Corporation": 1,
|
||||
"http://schema.org/EducationalOrganization": 1,
|
||||
"https://schema.org/EducationalOrganization": 1,
|
||||
"http://schema.org/GovernmentOrganization": 1,
|
||||
"https://schema.org/GovernmentOrganization": 1,
|
||||
"http://schema.org/MedicalOrganization": 1,
|
||||
"https://schema.org/MedicalOrganization": 1,
|
||||
"http://schema.org/AnimalShelter": 1,
|
||||
"https://schema.org/AnimalShelter": 1,
|
||||
"http://schema.org/AutomotiveBusiness": 1,
|
||||
"https://schema.org/AutomotiveBusiness": 1,
|
||||
"http://schema.org/ChildCare": 1,
|
||||
"https://schema.org/ChildCare": 1,
|
||||
"http://schema.org/DryCleaningOrLaundry": 1,
|
||||
"https://schema.org/DryCleaningOrLaundry": 1,
|
||||
"http://schema.org/EmergencyService": 1,
|
||||
"https://schema.org/EmergencyService": 1,
|
||||
"http://schema.org/EmploymentAgency": 1,
|
||||
"https://schema.org/EmploymentAgency": 1,
|
||||
"http://schema.org/EntertainmentBusiness": 1,
|
||||
"https://schema.org/EntertainmentBusiness": 1,
|
||||
"http://schema.org/FinancialService": 1,
|
||||
"https://schema.org/FinancialService": 1,
|
||||
"http://schema.org/FoodEstablishment": 1,
|
||||
"https://schema.org/FoodEstablishment": 1,
|
||||
"http://schema.org/GovernmentOffice": 1,
|
||||
"https://schema.org/GovernmentOffice": 1,
|
||||
"http://schema.org/HealthAndBeautyBusiness": 1,
|
||||
"https://schema.org/HealthAndBeautyBusiness": 1,
|
||||
"http://schema.org/HomeAndConstructionBusiness": 1,
|
||||
"https://schema.org/HomeAndConstructionBusiness": 1,
|
||||
"http://schema.org/InternetCafe": 1,
|
||||
"https://schema.org/InternetCafe": 1,
|
||||
"http://schema.org/LegalService": 1,
|
||||
"https://schema.org/LegalService": 1,
|
||||
"http://schema.org/Library": 1,
|
||||
"https://schema.org/Library": 1,
|
||||
"http://schema.org/LodgingBusiness": 1,
|
||||
"https://schema.org/LodgingBusiness": 1,
|
||||
"http://schema.org/ProfessionalService": 1,
|
||||
"https://schema.org/ProfessionalService": 1,
|
||||
"http://schema.org/RadioStation": 1,
|
||||
"https://schema.org/RadioStation": 1,
|
||||
"http://schema.org/RealEstateAgent": 1,
|
||||
"https://schema.org/RealEstateAgent": 1,
|
||||
"http://schema.org/RecyclingCenter": 1,
|
||||
"https://schema.org/RecyclingCenter": 1,
|
||||
"http://schema.org/SelfStorage": 1,
|
||||
"https://schema.org/SelfStorage": 1,
|
||||
"http://schema.org/ShoppingCenter": 1,
|
||||
"https://schema.org/ShoppingCenter": 1,
|
||||
"http://schema.org/SportsActivityLocation": 1,
|
||||
"https://schema.org/SportsActivityLocation": 1,
|
||||
"http://schema.org/Store": 1,
|
||||
"https://schema.org/Store": 1,
|
||||
"http://schema.org/TelevisionStation": 1,
|
||||
"https://schema.org/TelevisionStation": 1,
|
||||
"http://schema.org/TouristInformationCenter": 1,
|
||||
"https://schema.org/TouristInformationCenter": 1,
|
||||
"http://schema.org/TravelAgency": 1,
|
||||
"https://schema.org/TravelAgency": 1,
|
||||
}),
|
||||
(SchemaDataExtractor.validBaseSchemaTypes = {
|
||||
"http://schema.org/PostalAddress": 1,
|
||||
"https://schema.org/PostalAddress": 1,
|
||||
}),
|
||||
(SchemaDataExtractor.containsSchemaOrgKey = "containsSchemaOrg"),
|
||||
(SchemaDataExtractor.containsMicrodataKey = "containsMicrodata"),
|
||||
(SchemaDataExtractor.schemaOrgTypeDomain = "schema.org"),
|
||||
(SchemaDataExtractor.prototype = {
|
||||
isValidParentSchemaType: function (t) {
|
||||
return SchemaDataExtractor.validParentSchemaTypes[t];
|
||||
},
|
||||
isValidBaseSchemaType: function (t) {
|
||||
return SchemaDataExtractor.validBaseSchemaTypes[t];
|
||||
},
|
||||
extractFilteredSchemaValuesFromMicroData: function () {
|
||||
const t = document.querySelectorAll("[itemscope]");
|
||||
let e = [],
|
||||
r = [],
|
||||
a = !1;
|
||||
for (let o of t) {
|
||||
let t = o.getAttribute("itemType");
|
||||
t &&
|
||||
(this.isValidParentSchemaType(t) && e.push(o),
|
||||
this.isValidBaseSchemaType(t) && r.push(o),
|
||||
!a &&
|
||||
t.includes(SchemaDataExtractor.schemaOrgTypeDomain) &&
|
||||
(a = !0));
|
||||
}
|
||||
let o = {};
|
||||
if (!a) return o;
|
||||
if (((o[SchemaDataExtractor.containsSchemaOrgKey] = !0), 1 !== r.length))
|
||||
return o;
|
||||
const s = r[0],
|
||||
c = s.getAttribute("itemtype");
|
||||
if (!c || -1 === c.indexOf("PostalAddress")) return o;
|
||||
const n = s.querySelectorAll("[itemprop]");
|
||||
for (let t of n) {
|
||||
let e = t.getAttribute("itemprop");
|
||||
e &&
|
||||
SchemaDataExtractor.validAddressProperties[e] &&
|
||||
(o[e] = t.textContent ? t.textContent : t.getAttribute("content"));
|
||||
}
|
||||
let h = s.parentNode;
|
||||
for (; null !== h && -1 === e.indexOf(h);) h = h.parentNode;
|
||||
const i = s.querySelectorAll("[itemprop='telephone']");
|
||||
if (null !== h) {
|
||||
let t = h.querySelectorAll("[itemprop='name']");
|
||||
(t.length && (o.name = t[0].textContent),
|
||||
0 === i.length && (i = h.querySelectorAll("[itemprop='telephone']")));
|
||||
}
|
||||
return (i.length && (o.telephone = i[0].textContent), o);
|
||||
},
|
||||
extractAllSchemaValuesFromMicroData: function () {
|
||||
const t = document.querySelectorAll("[itemscope]");
|
||||
let e = [],
|
||||
r = !1;
|
||||
for (let a of t) {
|
||||
const t = a.getAttribute("itemType");
|
||||
t &&
|
||||
(e.push(a),
|
||||
!r &&
|
||||
t.includes(SchemaDataExtractor.schemaOrgTypeDomain) &&
|
||||
(r = !0));
|
||||
}
|
||||
let a = {};
|
||||
if (!r) return a;
|
||||
if (((a[SchemaDataExtractor.containsSchemaOrgKey] = !0), 1 !== e.length))
|
||||
return a;
|
||||
const o = e[0],
|
||||
s = (o.getAttribute("itemtype"), o.querySelectorAll("[itemprop]"));
|
||||
for (let t of s) {
|
||||
let e = t.getAttribute("itemprop");
|
||||
e && (a[e] = t.textContent ? t.textContent : t.getAttribute("content"));
|
||||
}
|
||||
return a;
|
||||
},
|
||||
extractFilteredSchemaValuesFromJSONLD: function () {
|
||||
let t = {};
|
||||
const e = document.querySelector('script[type="application/ld+json"]');
|
||||
if (!e) return t;
|
||||
let r;
|
||||
try {
|
||||
r = JSON.parse(e.text);
|
||||
} catch (e) {
|
||||
return t;
|
||||
}
|
||||
let a = r["@context"];
|
||||
if ("http://schema.org" !== a && "https://schema.org" !== a) return t;
|
||||
t[SchemaDataExtractor.containsSchemaOrgKey] = !0;
|
||||
let o = [];
|
||||
for (o.unshift(r); o.length;) {
|
||||
let e = o.shift();
|
||||
if (null != e) {
|
||||
if (
|
||||
(Object.prototype.hasOwnProperty.call(e, "telephone") &&
|
||||
(t.telephone = e.telephone),
|
||||
"PostalAddress" === e["@type"])
|
||||
) {
|
||||
for (let r in e)
|
||||
SchemaDataExtractor.validAddressProperties[r] && (t[r] = e[r]);
|
||||
break;
|
||||
}
|
||||
for (let t in e) {
|
||||
let r = e[t];
|
||||
"object" == typeof r && o.push(r);
|
||||
}
|
||||
}
|
||||
}
|
||||
return t;
|
||||
},
|
||||
extractAllSchemaValuesFromJSONLD: function () {
|
||||
let t = {};
|
||||
const e = document.querySelector('script[type="application/ld+json"]');
|
||||
if (!e) return t;
|
||||
let r, a;
|
||||
try {
|
||||
r = JSON.parse(e.text);
|
||||
} catch (e) {
|
||||
return t;
|
||||
}
|
||||
if (
|
||||
((a = Array.isArray(r) ? r[0]["@context"] : r["@context"]),
|
||||
"http://schema.org" !== a && "https://schema.org" !== a)
|
||||
)
|
||||
return t;
|
||||
t[SchemaDataExtractor.containsSchemaOrgKey] = !0;
|
||||
let o = [];
|
||||
o.unshift(r);
|
||||
const s = o.shift();
|
||||
for (let e in s) t[e] = s[e];
|
||||
return t;
|
||||
},
|
||||
resultHasAddressOrTelephone: function (t) {
|
||||
return (
|
||||
null != t &&
|
||||
(Object.prototype.hasOwnProperty.call(t, "streetAddress") ||
|
||||
Object.prototype.hasOwnProperty.call(t, "telephone"))
|
||||
);
|
||||
},
|
||||
resultHasSchemaOrgInfo: function (t) {
|
||||
return (
|
||||
null != t &&
|
||||
Object.prototype.hasOwnProperty.call(
|
||||
t,
|
||||
SchemaDataExtractor.containsSchemaOrgKey,
|
||||
)
|
||||
);
|
||||
},
|
||||
extractSchemaValuesFromSchemaOrg: function () {
|
||||
let t = this.extractAllSchemaValuesFromMicroData(),
|
||||
e = this.extractFilteredSchemaValuesFromMicroData();
|
||||
return (
|
||||
this.resultHasAddressOrTelephone(e) ||
|
||||
(e = this.extractFilteredSchemaValuesFromJSONLD()),
|
||||
this.resultHasAddressOrTelephone(t) ||
|
||||
(t = this.extractAllSchemaValuesFromJSONLD()),
|
||||
(this.resultHasAddressOrTelephone(e) ||
|
||||
this.resultHasSchemaOrgInfo(e)) &&
|
||||
(e.url = location.href),
|
||||
[e, t]
|
||||
);
|
||||
},
|
||||
}),
|
||||
"undefined" == typeof SchemaDataExtractorJS &&
|
||||
(SchemaDataExtractorJS = new SchemaDataExtractor()),
|
||||
SchemaDataExtractorJS.extractSchemaValuesFromSchemaOrg());
|
||||
20
27.0/js/schema/SchemaOrgMarkupChecker.js
Normal file
20
27.0/js/schema/SchemaOrgMarkupChecker.js
Normal file
@@ -0,0 +1,20 @@
|
||||
//# sourceURL=__InjectedScript_SchemaOrgMarkupChecker.js
|
||||
/* Copyright (c) 2026 Apple Inc. All rights reserved. */
|
||||
(function () {
|
||||
const e = "schema.org";
|
||||
var t = document.querySelectorAll('script[type="application/ld+json"]');
|
||||
for (let o of t) {
|
||||
var r;
|
||||
try {
|
||||
r = JSON.parse(o.text);
|
||||
} catch (e) {
|
||||
continue;
|
||||
}
|
||||
if (r["@context"].toLowerCase().includes(e)) return !0;
|
||||
}
|
||||
var o = document.querySelectorAll("[itemscope]");
|
||||
for (let t of o) {
|
||||
var c = t.getAttribute("itemType");
|
||||
if (c && c.toLowerCase().includes(e)) return !0;
|
||||
}
|
||||
})();
|
||||
20
27.0/js/search/OpenSearchURLFinder.js
Normal file
20
27.0/js/search/OpenSearchURLFinder.js
Normal file
@@ -0,0 +1,20 @@
|
||||
//# sourceURL=__InjectedScript_OpenSearchURLFinder.js
|
||||
/* Copyright (c) 2026 Apple Inc. All rights reserved. */
|
||||
(function () {
|
||||
"use strict";
|
||||
function e() {
|
||||
if (document.head) {
|
||||
var e = document.head.getElementsByTagName("link");
|
||||
for (const t of e)
|
||||
if (
|
||||
"search" === t.getAttribute("rel") &&
|
||||
"application/opensearchdescription+xml" === t.getAttribute("type")
|
||||
)
|
||||
return void window.webkit.messageHandlers.quickWebsiteSearchFoundOpenSearchURL.postMessage(
|
||||
t.href,
|
||||
);
|
||||
}
|
||||
}
|
||||
e();
|
||||
})();
|
||||
0;
|
||||
190
27.0/js/search/QuickWebsiteSearchURLDetector.js
Normal file
190
27.0/js/search/QuickWebsiteSearchURLDetector.js
Normal file
@@ -0,0 +1,190 @@
|
||||
//# sourceURL=__InjectedScript_QuickWebsiteSearchURLDetector.js
|
||||
/* Copyright (c) 2026 Apple Inc. All rights reserved. */
|
||||
(function () {
|
||||
"use strict";
|
||||
function e(e) {
|
||||
return encodeURIComponent(e).replace(/%20/g, "+");
|
||||
}
|
||||
function t(e) {
|
||||
return new RegExp("(^|.)" + e.replaceAll(".", "\\.") + "$");
|
||||
}
|
||||
function n(e) {
|
||||
return t(e).test(document.location.hostname);
|
||||
}
|
||||
function r(e) {
|
||||
if (e instanceof HTMLTextAreaElement) return !0;
|
||||
if (!(e instanceof HTMLInputElement)) return !1;
|
||||
const t = {
|
||||
date: !0,
|
||||
"datetime-local": !0,
|
||||
email: !0,
|
||||
isindex: !0,
|
||||
month: !0,
|
||||
number: !0,
|
||||
password: !0,
|
||||
search: !0,
|
||||
tel: !0,
|
||||
telephone: !0,
|
||||
text: !0,
|
||||
time: !0,
|
||||
url: !0,
|
||||
week: !0,
|
||||
};
|
||||
var n = e.type;
|
||||
return !n || n in t;
|
||||
}
|
||||
function u(e, t) {
|
||||
try {
|
||||
return window.collectMatchingElementsInFlatTree(e, t);
|
||||
} catch (e) {
|
||||
return [];
|
||||
}
|
||||
}
|
||||
function i(e) {
|
||||
e.elements;
|
||||
return u(
|
||||
e,
|
||||
"button, fieldset, input:not([type='image']), object, output, select, textarea",
|
||||
);
|
||||
}
|
||||
function o(e) {
|
||||
var t = e.localName;
|
||||
return "string" == typeof t || "string" == typeof (t = e.nodeName)
|
||||
? t
|
||||
: void 0;
|
||||
}
|
||||
function c(e) {
|
||||
let t = e.options,
|
||||
n = t.length;
|
||||
for (var r = 0; r < n; ++r) {
|
||||
let n = t[r];
|
||||
if (n.selected !== n.defaultSelected) {
|
||||
if (n.defaultSelected) return !1;
|
||||
if (e.multiple || r) return !1;
|
||||
}
|
||||
}
|
||||
return !0;
|
||||
}
|
||||
function l(e) {
|
||||
return (
|
||||
(e instanceof HTMLButtonElement || e instanceof HTMLInputElement) &&
|
||||
e.type &&
|
||||
"submit" === e.type
|
||||
);
|
||||
}
|
||||
function s(e) {
|
||||
if (!(e instanceof HTMLInputElement)) return !1;
|
||||
try {
|
||||
if (e.matches(":-webkit-autofill-strong-password")) return !0;
|
||||
} catch (e) {}
|
||||
const t = getComputedStyle(e, null).getPropertyValue(
|
||||
"-webkit-text-security",
|
||||
),
|
||||
r = e.type;
|
||||
if ("none" !== t || "password" === r) return !0;
|
||||
if (r && "text" !== r) return !1;
|
||||
if (n("ninehours.co.jp")) {
|
||||
let t = e.name;
|
||||
if ("guestPassword" === t || "guestPasswordConfirm" === t) return !0;
|
||||
}
|
||||
return !1;
|
||||
}
|
||||
function a(e) {
|
||||
return e.checked === e.defaultChecked;
|
||||
}
|
||||
function f(e) {
|
||||
return (
|
||||
e instanceof HTMLTextAreaElement &&
|
||||
("search" === e.getAttribute("type") ||
|
||||
"search" === e.inputMode ||
|
||||
"search" === e.getAttribute("enterkeyhint"))
|
||||
);
|
||||
}
|
||||
function d(e) {
|
||||
const t = o(e).toLowerCase();
|
||||
if ("button" === t || "fieldset" === t) return !0;
|
||||
if ("select" === t) return c(e);
|
||||
if ("input" !== t && !f(e)) return !1;
|
||||
const n = e.type;
|
||||
return "radio" === n || "checkbox" === n
|
||||
? a(e)
|
||||
: "hidden" === n ||
|
||||
"reset" === n ||
|
||||
"submit" === n ||
|
||||
"button" === n ||
|
||||
"image" === n ||
|
||||
(r(e) && !s(e));
|
||||
}
|
||||
function h(e) {
|
||||
if ("get" !== e.method) return !1;
|
||||
const t = i(e),
|
||||
n = t.length;
|
||||
for (let e = 0; e < n; ++e) if (!d(t[e])) return !1;
|
||||
return !0;
|
||||
}
|
||||
function m(e) {
|
||||
let t = [],
|
||||
n = i(e),
|
||||
u = n.length;
|
||||
for (let e = 0; e < u; ++e) {
|
||||
let u = n[e];
|
||||
u.checkVisibility() &&
|
||||
null != u.value &&
|
||||
u.value.length &&
|
||||
r(u) &&
|
||||
t.push(u);
|
||||
}
|
||||
return t;
|
||||
}
|
||||
function p(e) {
|
||||
if (e.disabled) return !1;
|
||||
if (!e.name.length) return !1;
|
||||
if (!e.value.length) return !1;
|
||||
if (e instanceof HTMLSelectElement) return !0;
|
||||
var t = o(e).toLowerCase(),
|
||||
n = e.type;
|
||||
return "button" === t
|
||||
? "submit" === n
|
||||
: "input" === t &&
|
||||
("submit" === n ||
|
||||
("checkbox" === n || "radio" === n
|
||||
? e.checked
|
||||
: "hidden" === n || r(e)));
|
||||
}
|
||||
function g(t) {
|
||||
const n = t.form;
|
||||
if (!n) return null;
|
||||
let r = n.getAttribute("action");
|
||||
if (!r || !r.length) return null;
|
||||
if (!/^https?:/i.test(n.action)) return null;
|
||||
let u = null,
|
||||
o = "",
|
||||
c = i(n),
|
||||
s = c.length;
|
||||
for (let n = 0; n < s; ++n) {
|
||||
let r = c[n];
|
||||
if ((r === t || p(r)) && (!l(r) || (u || (u = r), r === u))) {
|
||||
o.length && (o += "&");
|
||||
var a = r === t ? "{searchTerms}" : e(r.value);
|
||||
o += e(r.name) + "=" + a;
|
||||
}
|
||||
}
|
||||
let f = document.createElement("a");
|
||||
return ((f.href = n.action), (f.search = o), f.href);
|
||||
}
|
||||
function b(e) {
|
||||
const t = e.target;
|
||||
if (!h(t)) return;
|
||||
const n = m(t);
|
||||
if (n.length > 1) return;
|
||||
const r = n[0];
|
||||
if (!r) return;
|
||||
const u = g(r);
|
||||
u &&
|
||||
window.webkit.messageHandlers.quickWebsiteSearchDetectedSearchURL.postMessage(
|
||||
u,
|
||||
);
|
||||
}
|
||||
window.addEventListener("submit", b);
|
||||
})();
|
||||
0;
|
||||
246
27.0/js/search/SearchEngineBannerDetector.js
Normal file
246
27.0/js/search/SearchEngineBannerDetector.js
Normal file
@@ -0,0 +1,246 @@
|
||||
//# sourceURL=__InjectedScript_SearchEngineBannerDetector.js
|
||||
/* Copyright (c) 2026 Apple Inc. All rights reserved. */
|
||||
(function () {
|
||||
function e(e) {
|
||||
try {
|
||||
var t =
|
||||
window.webkit &&
|
||||
window.webkit.messageHandlers &&
|
||||
window.webkit.messageHandlers.safariSearchEngineBannerDetection;
|
||||
t && t.postMessage({ kind: e, category: M });
|
||||
} catch (e) {}
|
||||
}
|
||||
function t() {
|
||||
if (C) {
|
||||
try {
|
||||
C.disconnect();
|
||||
} catch (e) {}
|
||||
C = null;
|
||||
}
|
||||
q.length = 0;
|
||||
}
|
||||
function n() {
|
||||
if (_) {
|
||||
try {
|
||||
_.disconnect();
|
||||
} catch (e) {}
|
||||
_ = null;
|
||||
}
|
||||
if (B) {
|
||||
try {
|
||||
document.removeEventListener("pointerdown", B, !0);
|
||||
} catch (e) {}
|
||||
B = null;
|
||||
}
|
||||
D.length = 0;
|
||||
}
|
||||
function r() {
|
||||
(t(), n());
|
||||
}
|
||||
function i(e) {
|
||||
if (!e || !e.getAttribute) return null;
|
||||
var t = e.getAttribute("href") || "";
|
||||
return 0 === t.indexOf("googlechrome://") ||
|
||||
(0 === t.indexOf("intent://") &&
|
||||
-1 !== t.indexOf("scheme=googlechrome")) ||
|
||||
-1 !== t.indexOf("id535886823")
|
||||
? E
|
||||
: 0 === t.indexOf("comgoogleapp://") || -1 !== t.indexOf("id284815942")
|
||||
? O
|
||||
: null;
|
||||
}
|
||||
function o(e) {
|
||||
for (
|
||||
var t = e && e.querySelectorAll ? e.querySelectorAll("a[href]") : [],
|
||||
n = 0;
|
||||
n < t.length;
|
||||
n++
|
||||
) {
|
||||
var r = i(t[n]);
|
||||
if (r) return r;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
function a(e) {
|
||||
return null !== o(e);
|
||||
}
|
||||
function u(e) {
|
||||
var t = o(e);
|
||||
return (
|
||||
t || (-1 !== ((e && e.textContent) || "").indexOf("Chrome") ? E : "other")
|
||||
);
|
||||
}
|
||||
function d(e) {
|
||||
return (
|
||||
!(!e || !e.isConnected) &&
|
||||
(!e.getAttribute || "true" !== e.getAttribute("aria-hidden"))
|
||||
);
|
||||
}
|
||||
function l(e) {
|
||||
var t = e.ownerDocument && e.ownerDocument.defaultView;
|
||||
if (!t) return !1;
|
||||
var n = t.getComputedStyle(e);
|
||||
return !!n && "hidden" !== n.visibility && "none" !== n.display;
|
||||
}
|
||||
function c(e) {
|
||||
return d(e) && l(e);
|
||||
}
|
||||
function f(e) {
|
||||
if (!e || !e.getBoundingClientRect) return !1;
|
||||
var t = e.getBoundingClientRect();
|
||||
return t.width > 0 && t.height > 0;
|
||||
}
|
||||
function s(e) {
|
||||
d(e) &&
|
||||
("promo_label_id" !==
|
||||
(e.getAttribute && e.getAttribute("aria-labelledby"))
|
||||
? a(e) && l(e) && b(e)
|
||||
: l(e) && b(e));
|
||||
}
|
||||
function g(e) {
|
||||
for (
|
||||
var t = e.querySelectorAll
|
||||
? e.querySelectorAll('[data-async-type="hpba"]')
|
||||
: [],
|
||||
n = 0;
|
||||
n < t.length;
|
||||
n++
|
||||
) {
|
||||
var r = t[n];
|
||||
if (d(r) && r.children && r.children.length > 0 && l(r) && f(r))
|
||||
return void b(r);
|
||||
}
|
||||
}
|
||||
function h(e) {
|
||||
if (
|
||||
!L &&
|
||||
e &&
|
||||
e.querySelectorAll &&
|
||||
!(
|
||||
1 === e.nodeType &&
|
||||
e.matches &&
|
||||
e.matches('[role="dialog"]') &&
|
||||
(s(e), L)
|
||||
)
|
||||
) {
|
||||
for (
|
||||
var t = e.querySelectorAll('[role="dialog"]'), n = 0;
|
||||
n < t.length;
|
||||
n++
|
||||
)
|
||||
if ((s(t[n]), L)) return;
|
||||
g(e);
|
||||
}
|
||||
}
|
||||
function v() {
|
||||
if (((k = !1), L)) q.length = 0;
|
||||
else {
|
||||
var e = q;
|
||||
q = [];
|
||||
for (var t = 0; t < e.length && !L; t++) h(e[t]);
|
||||
}
|
||||
}
|
||||
function m(e) {
|
||||
if (!L && e && (q.push(e), !k)) {
|
||||
k = !0;
|
||||
var t = window.requestIdleCallback;
|
||||
t ? t(v, { timeout: 500 }) : setTimeout(v, 16);
|
||||
}
|
||||
}
|
||||
function b(n) {
|
||||
L || ((L = !0), (M = u(n)), e("appearance"), t(), p(n));
|
||||
}
|
||||
function w() {
|
||||
x || ((x = !0), e("dismissed"), n());
|
||||
}
|
||||
function y() {
|
||||
if (!T && ((T = !0), e("interaction"), B)) {
|
||||
try {
|
||||
document.removeEventListener("pointerdown", B, !0);
|
||||
} catch (e) {}
|
||||
B = null;
|
||||
}
|
||||
}
|
||||
function p(e) {
|
||||
e &&
|
||||
(D.push(e),
|
||||
(B = function (e) {
|
||||
if (!T) {
|
||||
var t = e.target;
|
||||
if (t)
|
||||
for (var n = 0; n < D.length; n++) {
|
||||
var r = D[n];
|
||||
if (r.contains && r.contains(t)) return void y();
|
||||
}
|
||||
}
|
||||
}),
|
||||
document.addEventListener("pointerdown", B, !0),
|
||||
(_ = new MutationObserver(function (e) {
|
||||
if (!x) {
|
||||
for (var t = !1, n = 0; n < e.length; n++)
|
||||
if ("attributes" === e[n].type) {
|
||||
t = !0;
|
||||
break;
|
||||
}
|
||||
for (var r = 0; r < D.length; r++) if (t ? c(D[r]) : d(D[r])) return;
|
||||
w();
|
||||
}
|
||||
})).observe(document.documentElement, { childList: !0, subtree: !0 }),
|
||||
_.observe(e, {
|
||||
attributes: !0,
|
||||
attributeFilter: ["aria-hidden", "style", "class", "hidden"],
|
||||
}));
|
||||
}
|
||||
function A() {
|
||||
function e() {
|
||||
setTimeout(t, S);
|
||||
}
|
||||
(h(document),
|
||||
window.addEventListener("pagehide", r, { once: !0 }),
|
||||
L ||
|
||||
((C = new MutationObserver(function (e) {
|
||||
if (!L)
|
||||
for (var t = 0; t < e.length; t++) {
|
||||
var n = e[t];
|
||||
if (
|
||||
"attributes" === n.type &&
|
||||
n.target &&
|
||||
1 === n.target.nodeType
|
||||
)
|
||||
m(n.target);
|
||||
else if (n.addedNodes)
|
||||
for (var r = 0; r < n.addedNodes.length; r++) {
|
||||
var i = n.addedNodes[r];
|
||||
1 === i.nodeType && m(i);
|
||||
}
|
||||
}
|
||||
})).observe(document.documentElement, {
|
||||
childList: !0,
|
||||
subtree: !0,
|
||||
attributes: !0,
|
||||
attributeFilter: ["aria-hidden"],
|
||||
}),
|
||||
"complete" === document.readyState
|
||||
? e()
|
||||
: window.addEventListener("load", e, { once: !0 })));
|
||||
}
|
||||
if (window.__safariSearchEngineBannerDetectorInstalled) return;
|
||||
window.__safariSearchEngineBannerDetectorInstalled = !0;
|
||||
var S = 1e4;
|
||||
const E = "chrome",
|
||||
O = "googleApp";
|
||||
var L = !1,
|
||||
x = !1,
|
||||
C = null,
|
||||
q = [],
|
||||
k = !1,
|
||||
D = [],
|
||||
_ = null,
|
||||
B = null,
|
||||
T = !1,
|
||||
M = null;
|
||||
"loading" === document.readyState
|
||||
? document.addEventListener("DOMContentLoaded", A, { once: !0 })
|
||||
: A();
|
||||
})();
|
||||
0;
|
||||
6
27.0/js/translation/Translation.js
Normal file
6
27.0/js/translation/Translation.js
Normal file
@@ -0,0 +1,6 @@
|
||||
//# sourceURL=__InjectedScript_Translation.js
|
||||
/* Copyright (c) 2026 Apple Inc. All rights reserved. */
|
||||
function updateLanguageAttributesForTranslation(n) {
|
||||
document.documentElement.lang && (document.documentElement.lang = n);
|
||||
}
|
||||
0;
|
||||
750
27.0/js/utilities/NodePath.js
Normal file
750
27.0/js/utilities/NodePath.js
Normal file
@@ -0,0 +1,750 @@
|
||||
//# sourceURL=__InjectedScript_NodePath.js
|
||||
/* Copyright (c) 2026 Apple Inc. All rights reserved. */
|
||||
// Copyright (C) 2023-2024 Apple Inc. All rights reserved.
|
||||
"use strict";
|
||||
(globalThis.WAS || (globalThis.WAS = {}),
|
||||
(WAS.NodePath = class {
|
||||
static {
|
||||
function e(e, t) {
|
||||
if (e === t) return 0;
|
||||
for (
|
||||
var n = e.length, o = t.length, a = new Array(n + 1), i = 0;
|
||||
i < n + 1;
|
||||
++i
|
||||
)
|
||||
((a[i] = new Array(o + 1)), (a[i][0] = i));
|
||||
for (var s = 0; s < o + 1; ++s) a[0][s] = s;
|
||||
for (s = 1; s < o + 1; ++s) {
|
||||
let o = t[s - 1];
|
||||
for (i = 1; i < n + 1; ++i)
|
||||
if (e[i - 1] === o) a[i][s] = a[i - 1][s - 1];
|
||||
else {
|
||||
var d = a[i - 1][s] + 1,
|
||||
r = a[i][s - 1] + 1,
|
||||
h = a[i - 1][s - 1] + 1;
|
||||
a[i][s] = Math.min(d, r, h);
|
||||
}
|
||||
}
|
||||
return a[n][o];
|
||||
}
|
||||
((WAS.Assert =
|
||||
WAS.Assert ||
|
||||
class {
|
||||
static isTrue(e, t, ...n) {}
|
||||
static isType(e, ...t) {}
|
||||
static optionalIsType(e, ...t) {}
|
||||
static arrayContentIsType(e, ...t) {}
|
||||
static optionalArrayContentIsType(e, ...t) {}
|
||||
static isEnum(e, t) {}
|
||||
static optionalIsEnum(e, t) {}
|
||||
static isSubclass(e, t) {}
|
||||
static notReached(e, ...t) {}
|
||||
}),
|
||||
Object.defineProperties(CharacterData, {
|
||||
nodePath_isCharacterData: {
|
||||
value(e) {
|
||||
switch (Node.nodePath_nodeType(e)) {
|
||||
case Node.TEXT_NODE:
|
||||
case Node.CDATA_SECTION_NODE:
|
||||
case Node.PROCESSING_INSTRUCTION_NODE:
|
||||
case Node.COMMENT_NODE:
|
||||
return !0;
|
||||
default:
|
||||
return !1;
|
||||
}
|
||||
},
|
||||
},
|
||||
nodePath_data: {
|
||||
value: (e) =>
|
||||
CharacterData.nodePath_isCharacterData(e)
|
||||
? Object.nodePath_get(e, CharacterData, "data")
|
||||
: null,
|
||||
},
|
||||
}),
|
||||
Object.defineProperties(Document, {
|
||||
nodePath_isDocument: {
|
||||
value: (e) => Node.nodePath_nodeType(e) === Node.DOCUMENT_NODE,
|
||||
},
|
||||
nodePath_defaultView: {
|
||||
value: (e) =>
|
||||
Document.nodePath_isDocument(e)
|
||||
? Object.nodePath_get(e, Document, "defaultView")
|
||||
: null,
|
||||
},
|
||||
}),
|
||||
Object.defineProperties(Element, {
|
||||
nodePath_isElement: {
|
||||
value: (e) => Node.nodePath_nodeType(e) === Node.ELEMENT_NODE,
|
||||
},
|
||||
nodePath_tagName: {
|
||||
value: (e) =>
|
||||
Element.nodePath_isElement(e)
|
||||
? Object.nodePath_get(e, Element, "tagName")
|
||||
: null,
|
||||
},
|
||||
nodePath_id: {
|
||||
value: (e) =>
|
||||
Element.nodePath_isElement(e)
|
||||
? Object.nodePath_get(e, Element, "id")
|
||||
: null,
|
||||
},
|
||||
nodePath_className: {
|
||||
value: (e) =>
|
||||
Element.nodePath_isElement(e)
|
||||
? Object.nodePath_get(e, Element, "className")
|
||||
: null,
|
||||
},
|
||||
nodePath_shadowRoot: {
|
||||
value: (e) =>
|
||||
Element.nodePath_isElement(e)
|
||||
? Object.nodePath_get(e, Element, "shadowRoot")
|
||||
: null,
|
||||
},
|
||||
nodePath_querySelectorAll: {
|
||||
value: (e, t) =>
|
||||
Element.nodePath_isElement(e)
|
||||
? Element.prototype.querySelectorAll.call(e, t)
|
||||
: null,
|
||||
},
|
||||
}),
|
||||
Object.defineProperties(HTMLIFrameElement, {
|
||||
nodePath_isHTMLIFrameElement: {
|
||||
value: (e) =>
|
||||
Node.nodePath_nodeType(e) === Node.ELEMENT_NODE &&
|
||||
"HTMLIFrameElement" === Object.getPrototypeOf(e).constructor.name,
|
||||
},
|
||||
nodePath_contentWindowDocument: {
|
||||
value(e) {
|
||||
if (!HTMLIFrameElement.nodePath_isHTMLIFrameElement(e))
|
||||
return null;
|
||||
try {
|
||||
return Object.nodePath_get(
|
||||
e,
|
||||
HTMLIFrameElement,
|
||||
"contentWindow",
|
||||
).document;
|
||||
} catch (e) {
|
||||
return null;
|
||||
}
|
||||
},
|
||||
},
|
||||
}),
|
||||
Object.defineProperties(Node, {
|
||||
nodePath_nodeType: {
|
||||
value: (e) => (
|
||||
WAS.Assert.isType(e, Node),
|
||||
Object.nodePath_get(e, Node, "nodeType")
|
||||
),
|
||||
},
|
||||
nodePath_firstChild: {
|
||||
value: (e) => (
|
||||
WAS.Assert.isType(e, Node),
|
||||
Object.nodePath_get(e, Node, "firstChild")
|
||||
),
|
||||
},
|
||||
nodePath_nextSibling: {
|
||||
value: (e) => (
|
||||
WAS.Assert.isType(e, Node),
|
||||
Object.nodePath_get(e, Node, "nextSibling")
|
||||
),
|
||||
},
|
||||
nodePath_previousSibling: {
|
||||
value: (e) => (
|
||||
WAS.Assert.isType(e, Node),
|
||||
Object.nodePath_get(e, Node, "previousSibling")
|
||||
),
|
||||
},
|
||||
nodePath_childNodes: {
|
||||
value: (e) => (
|
||||
WAS.Assert.isType(e, Node),
|
||||
Object.nodePath_get(e, Node, "childNodes")
|
||||
),
|
||||
},
|
||||
nodePath_textContent: {
|
||||
value: (e) => (
|
||||
WAS.Assert.isType(e, Node),
|
||||
Object.nodePath_get(e, Node, "textContent")
|
||||
),
|
||||
},
|
||||
nodePath_cloneNode: {
|
||||
value: (e, { shouldIncludeSubtree: t }) => (
|
||||
WAS.Assert.isType(e, Node),
|
||||
Node.prototype.cloneNode.call(e, t)
|
||||
),
|
||||
},
|
||||
nodePath_isEmptyTextNode: {
|
||||
value: (e) =>
|
||||
Text.nodePath_isText(e) &&
|
||||
CharacterData.nodePath_data(e)
|
||||
.nodePath_isEmptyExcludingWhitespace,
|
||||
},
|
||||
nodePath_siblingIndexOfNode: {
|
||||
value(e) {
|
||||
let t = 0;
|
||||
for (
|
||||
let n = Node.nodePath_previousSibling(e);
|
||||
n;
|
||||
n = Node.nodePath_previousSibling(n)
|
||||
)
|
||||
Node.nodePath_includeWhenComputingSiblingIndex(n) && ++t;
|
||||
return t;
|
||||
},
|
||||
},
|
||||
nodePath_includeWhenComputingSiblingIndex: {
|
||||
value: (e) =>
|
||||
!(
|
||||
Node.nodePath_isEmptyTextNode(e) ||
|
||||
(Element.nodePath_isElement(e) &&
|
||||
"SCRIPT" === Element.nodePath_tagName(e).toUpperCase())
|
||||
),
|
||||
},
|
||||
nodePath_immediateSourceMarkupOfNode: {
|
||||
value: (e) =>
|
||||
Node.nodePath_nodeType(e) === Node.DOCUMENT_FRAGMENT_NODE
|
||||
? null
|
||||
: Node.nodePath_cloneNode(e, { shouldIncludeSubtree: !1 })
|
||||
.outerHTML,
|
||||
},
|
||||
nodePath_immediateInnerTextOfNode: {
|
||||
value(e) {
|
||||
if (!Node.prototype.hasChildNodes.call(e))
|
||||
return Node.nodePath_textContent(e)?.trim();
|
||||
let t = "";
|
||||
for (let n of Node.nodePath_childNodes(e))
|
||||
Text.nodePath_isText(n) &&
|
||||
(t += CharacterData.nodePath_data(n));
|
||||
return t.trim();
|
||||
},
|
||||
},
|
||||
nodePath_getBoundingClientRect: {
|
||||
value(e) {
|
||||
if ((WAS.Assert.isType(e, Node, Range), e instanceof Range))
|
||||
return e.getBoundingClientRect();
|
||||
if (Text.nodePath_isText(e)) {
|
||||
let t = new Range();
|
||||
return (
|
||||
t.setStart(e, 0),
|
||||
t.setEnd(e, CharacterData.nodePath_data(e).length),
|
||||
t.getBoundingClientRect()
|
||||
);
|
||||
}
|
||||
return Element.nodePath_isElement(e)
|
||||
? Element.prototype.getBoundingClientRect.call(e)
|
||||
: null;
|
||||
},
|
||||
},
|
||||
}),
|
||||
Object.defineProperties(Object, {
|
||||
nodePath_get: {
|
||||
value: (e, t, n) =>
|
||||
Object.getOwnPropertyDescriptor(t.prototype, n)?.get?.call?.(e),
|
||||
},
|
||||
}),
|
||||
Object.defineProperties(Range, {
|
||||
nodePath_fromNode: {
|
||||
value(e) {
|
||||
let t = new Range();
|
||||
return (t.selectNode(e), t);
|
||||
},
|
||||
},
|
||||
nodePath_isSingleElementRange: {
|
||||
value: (e) =>
|
||||
e.startContainer === e.endContainer &&
|
||||
!Text.nodePath_isText(e.commonAncestorContainer) &&
|
||||
1 === Math.abs(e.endOffset - e.startOffset),
|
||||
},
|
||||
nodePath_singleElementFromRange: {
|
||||
value: (e) =>
|
||||
Range.nodePath_isSingleElementRange(e)
|
||||
? Node.nodePath_childNodes(e.commonAncestorContainer)[
|
||||
e.startOffset
|
||||
]
|
||||
: null,
|
||||
},
|
||||
nodePath_startNodeFromRange: {
|
||||
value: (e) =>
|
||||
Text.nodePath_isText(e.startContainer)
|
||||
? null
|
||||
: Node.nodePath_childNodes(e.startContainer)[e.startOffset],
|
||||
},
|
||||
nodePath_endNodeFromRange: {
|
||||
value: (e) =>
|
||||
Text.nodePath_isText(e.endContainer)
|
||||
? Node.nodePath_childNodes(e.endContainer)[e.endOffset - 1]
|
||||
: null,
|
||||
},
|
||||
}),
|
||||
Object.defineProperties(Range.prototype, {
|
||||
nodePath_equals: {
|
||||
value(e) {
|
||||
return (
|
||||
this.commonAncestorContainer === e.commonAncestorContainer &&
|
||||
0 === this.compareBoundaryPoints(Range.START_TO_START, e) &&
|
||||
0 === this.compareBoundaryPoints(Range.END_TO_END, e)
|
||||
);
|
||||
},
|
||||
},
|
||||
}),
|
||||
Object.defineProperties(ShadowRoot, {
|
||||
nodePath_isShadowRoot: {
|
||||
value: (e) =>
|
||||
Node.nodePath_nodeType(e) === Node.DOCUMENT_FRAGMENT_NODE &&
|
||||
"ShadowRoot" === Object.getPrototypeOf(e).constructor.name,
|
||||
},
|
||||
nodePath_host: {
|
||||
value: (e) =>
|
||||
ShadowRoot.nodePath_isShadowRoot(e)
|
||||
? Object.nodePath_get(e, ShadowRoot, "host")
|
||||
: null,
|
||||
},
|
||||
}),
|
||||
Object.defineProperties(String, {
|
||||
_nodePath_matchAnyNonWhitespaceRegex: { value: /\S/ },
|
||||
}),
|
||||
Object.defineProperties(String.prototype, {
|
||||
nodePath_isEmptyExcludingWhitespace: {
|
||||
get() {
|
||||
return (
|
||||
!this.length ||
|
||||
!String._nodePath_matchAnyNonWhitespaceRegex.test(this)
|
||||
);
|
||||
},
|
||||
},
|
||||
nodePath_similarityTo: {
|
||||
value(t) {
|
||||
if (!t) return this.length ? 0 : 1;
|
||||
let n = Math.max(this.length, t.length);
|
||||
return n ? (n - e(this, t)) / n : 0;
|
||||
},
|
||||
},
|
||||
}),
|
||||
Object.defineProperties(Text, {
|
||||
nodePath_isText: {
|
||||
value: (e) => Node.nodePath_nodeType(e) === Node.TEXT_NODE,
|
||||
},
|
||||
}));
|
||||
}
|
||||
static ObjectRepresentationCodableInfo = { classPath: "WAS.NodePath" };
|
||||
static #e = class {
|
||||
#t;
|
||||
#n;
|
||||
#o;
|
||||
#a;
|
||||
#i;
|
||||
#s;
|
||||
#d;
|
||||
#r;
|
||||
constructor(
|
||||
e,
|
||||
t,
|
||||
{
|
||||
tag: n,
|
||||
id: o,
|
||||
classes: a,
|
||||
text: i,
|
||||
sourceMarkup: s,
|
||||
boundingClientRect: d,
|
||||
} = {},
|
||||
) {
|
||||
(WAS.Assert.isType(e, Number),
|
||||
WAS.Assert.isType(t, Number),
|
||||
WAS.Assert.optionalIsType(n, String),
|
||||
WAS.Assert.optionalIsType(o, String),
|
||||
WAS.Assert.optionalIsType(a, String),
|
||||
WAS.Assert.optionalIsType(i, String),
|
||||
WAS.Assert.optionalIsType(s, String),
|
||||
WAS.Assert.optionalIsType(d, Object),
|
||||
(this.#t = e),
|
||||
(this.#n = t),
|
||||
(this.#d = s),
|
||||
(this.#r = d),
|
||||
e === Node.ELEMENT_NODE
|
||||
? (WAS.Assert.isTrue(n, "Tag must be present for ELEMENT_NODEs"),
|
||||
(this.#o = n),
|
||||
(this.#a = o?.length ? o : void 0),
|
||||
(this.#i = a?.length ? a : void 0),
|
||||
(this.#s = i))
|
||||
: e === Node.TEXT_NODE && (this.#s = i));
|
||||
}
|
||||
static fromNode(e) {
|
||||
WAS.Assert.isType(e, Node);
|
||||
let t = Node.nodePath_nodeType(e),
|
||||
n = Node.nodePath_siblingIndexOfNode(e),
|
||||
o = {};
|
||||
if (Element.nodePath_isElement(e)) {
|
||||
((o.tag = Element.nodePath_tagName(e)),
|
||||
(o.id = Element.nodePath_id(e)),
|
||||
(o.classes = Element.nodePath_className(e)));
|
||||
let t = Node.nodePath_immediateInnerTextOfNode(e);
|
||||
t.length && (o.text = t);
|
||||
} else
|
||||
Text.nodePath_isText(e) && (o.text = CharacterData.nodePath_data(e));
|
||||
o.sourceMarkup = Node.nodePath_immediateSourceMarkupOfNode(e);
|
||||
let a = Node.nodePath_getBoundingClientRect(e);
|
||||
return (
|
||||
a &&
|
||||
(o.boundingClientRect = {
|
||||
x: a.x,
|
||||
y: a.y,
|
||||
width: a.width,
|
||||
height: a.height,
|
||||
}),
|
||||
new WAS.NodePath.#e(t, n, o)
|
||||
);
|
||||
}
|
||||
static fromObjectRepresentation(e) {
|
||||
return (
|
||||
WAS.Assert.isType(e, Object),
|
||||
new WAS.NodePath.#e(e.type, e.index, e)
|
||||
);
|
||||
}
|
||||
get objectRepresentation() {
|
||||
return {
|
||||
type: this.#t,
|
||||
index: this.#n,
|
||||
tag: this.#o,
|
||||
id: this.#a,
|
||||
classes: this.#i,
|
||||
text: this.#s,
|
||||
sourceMarkup: this.#d,
|
||||
boundingClientRect: this.#r,
|
||||
};
|
||||
}
|
||||
get type() {
|
||||
return this.#t;
|
||||
}
|
||||
get index() {
|
||||
return this.#n;
|
||||
}
|
||||
get tag() {
|
||||
return this.#o;
|
||||
}
|
||||
get id() {
|
||||
return this.#a;
|
||||
}
|
||||
get classes() {
|
||||
return this.#i;
|
||||
}
|
||||
get text() {
|
||||
return this.#s;
|
||||
}
|
||||
toElementCSSSelector() {
|
||||
if (this.type !== Node.ELEMENT_NODE) return null;
|
||||
let e = CSS.escape(this.tag);
|
||||
this.id && (e += `#${CSS.escape(this.id)}`);
|
||||
for (let t of this.classes?.split(" ") ?? [])
|
||||
t.length && (e += `.${CSS.escape(t)}`);
|
||||
return e;
|
||||
}
|
||||
toString() {
|
||||
return JSON.stringify(this.objectRepresentation);
|
||||
}
|
||||
equals(e) {
|
||||
return (
|
||||
WAS.Assert.optionalIsType(e, WAS.NodePath.#e),
|
||||
!!e &&
|
||||
this.#t === e.#t &&
|
||||
this.#n === e.#n &&
|
||||
this.#o === e.#o &&
|
||||
this.#a === e.#a &&
|
||||
this.#i === e.#i &&
|
||||
this.#s === e.#s
|
||||
);
|
||||
}
|
||||
};
|
||||
static #h = 1e3;
|
||||
static #l = 500;
|
||||
static #c = 200;
|
||||
static #m = 200;
|
||||
static #N = 100;
|
||||
static #p = 10;
|
||||
#u;
|
||||
#C;
|
||||
#_;
|
||||
#P;
|
||||
#A;
|
||||
#f;
|
||||
constructor(
|
||||
e,
|
||||
{
|
||||
startContainerAdditionalComponents: t,
|
||||
startContainerOffset: n,
|
||||
endContainerAdditionalComponents: o,
|
||||
endContainerOffset: a,
|
||||
} = {},
|
||||
) {
|
||||
(WAS.Assert.arrayContentIsType(e, WAS.NodePath.#e),
|
||||
WAS.Assert.isTrue(
|
||||
e[0]?.type == Node.DOCUMENT_NODE,
|
||||
"First path component should always be a document node.",
|
||||
),
|
||||
(this.#u = e),
|
||||
(this.#_ = t),
|
||||
(this.#P = n),
|
||||
(this.#A = o),
|
||||
(this.#f = a));
|
||||
}
|
||||
static #g(e, t) {
|
||||
WAS.Assert.isType(e, Node);
|
||||
let n = [],
|
||||
o = e,
|
||||
a = 0;
|
||||
for (; o && (++a, !(a > 512));) {
|
||||
let e;
|
||||
for (
|
||||
;
|
||||
o && (n.push(WAS.NodePath.#e.fromNode(o)), (e = o), o !== t);
|
||||
o = o.parentNode
|
||||
);
|
||||
if (e === t) break;
|
||||
let a = Document.nodePath_defaultView(e);
|
||||
if (a) {
|
||||
o = a.frameElement;
|
||||
continue;
|
||||
}
|
||||
let i = ShadowRoot.nodePath_host(e);
|
||||
i && (o = i);
|
||||
}
|
||||
return n.toReversed();
|
||||
}
|
||||
static from(e, t) {
|
||||
return e instanceof Range
|
||||
? WAS.NodePath.fromRange(e, t)
|
||||
: WAS.NodePath.fromNode(e, t);
|
||||
}
|
||||
static fromNode(e, t) {
|
||||
let n = new WAS.NodePath(WAS.NodePath.#g(e, t));
|
||||
return ((n.#C = new WeakRef(Range.nodePath_fromNode(e))), n);
|
||||
}
|
||||
static fromRange(e, t) {
|
||||
let n = Range.nodePath_singleElementFromRange(e);
|
||||
if (n) return WAS.NodePath.fromNode(n, t);
|
||||
let o,
|
||||
a,
|
||||
i,
|
||||
s,
|
||||
d = WAS.NodePath.#g(e.commonAncestorContainer, t),
|
||||
r = Range.nodePath_startNodeFromRange(e);
|
||||
r
|
||||
? (o = WAS.NodePath.#g(r, e.commonAncestorContainer).toSpliced(0, 1))
|
||||
: e.startContainer !== e.commonAncestorContainer
|
||||
? ((o = WAS.NodePath.#g(
|
||||
e.startContainer,
|
||||
e.commonAncestorContainer,
|
||||
).toSpliced(0, 1)),
|
||||
(a = e.startOffset))
|
||||
: (o = []);
|
||||
let h = Range.nodePath_endNodeFromRange(e);
|
||||
h
|
||||
? (i = WAS.NodePath.#g(h, e.commonAncestorContainer).toSpliced(0, 1))
|
||||
: e.endContainer !== e.commonAncestorContainer
|
||||
? ((i = WAS.NodePath.#g(
|
||||
e.endContainer,
|
||||
e.commonAncestorContainer,
|
||||
).toSpliced(0, 1)),
|
||||
(s = e.endOffset))
|
||||
: (i = []);
|
||||
let l = new WAS.NodePath(d, {
|
||||
startContainerAdditionalComponents: o,
|
||||
startContainerOffset: a,
|
||||
endContainerAdditionalComponents: i,
|
||||
endContainerOffset: s,
|
||||
});
|
||||
return ((l.#C = new WeakRef(e)), l);
|
||||
}
|
||||
static fromObjectRepresentation(e) {
|
||||
const t = (e) => (
|
||||
WAS.Assert.isType(e, Array),
|
||||
e.map((e) => WAS.NodePath.#e.fromObjectRepresentation(e))
|
||||
);
|
||||
return Array.isArray(e)
|
||||
? new WAS.NodePath(t(e))
|
||||
: (WAS.Assert.isType(e, Object),
|
||||
new WAS.NodePath(t(e.pathComponents), {
|
||||
startContainerAdditionalComponents:
|
||||
e.startContainerAdditionalComponents
|
||||
? t(e.startContainerAdditionalComponents)
|
||||
: void 0,
|
||||
startContainerOffset: e.startContainerOffset ?? void 0,
|
||||
endContainerAdditionalComponents: e.endContainerAdditionalComponents
|
||||
? t(e.endContainerAdditionalComponents)
|
||||
: void 0,
|
||||
endContainerOffset: e.endContainerOffset ?? void 0,
|
||||
}));
|
||||
}
|
||||
get objectRepresentation() {
|
||||
const e = (e) => (
|
||||
WAS.Assert.isType(e, Array),
|
||||
e.map((e) => e.objectRepresentation)
|
||||
);
|
||||
return {
|
||||
pathComponents: e(this.#u),
|
||||
startContainerAdditionalComponents: this.#_ ? e(this.#_) : void 0,
|
||||
startContainerOffset: this.#P,
|
||||
endContainerAdditionalComponents: this.#A ? e(this.#A) : void 0,
|
||||
endContainerOffset: this.#f,
|
||||
};
|
||||
}
|
||||
static nodePathIsKnownFormControlInputElement(e) {
|
||||
let t = e?.pathComponents.at(-1)?.tag?.toUpperCase();
|
||||
switch (t) {
|
||||
case "INPUT":
|
||||
case "SELECT":
|
||||
case "TEXTAREA":
|
||||
return !0;
|
||||
default:
|
||||
return !1;
|
||||
}
|
||||
}
|
||||
get pathComponents() {
|
||||
return this.#u;
|
||||
}
|
||||
get userFriendlySummary() {
|
||||
let e = this.#u.at(-1);
|
||||
return e.type === Node.TEXT_NODE
|
||||
? e.text.trim()
|
||||
: e.text
|
||||
? `${e.tag.toLowerCase()}: "${e.text.trim()}"`
|
||||
: e.tag.toLowerCase();
|
||||
}
|
||||
toString() {
|
||||
return JSON.stringify(this.objectRepresentation);
|
||||
}
|
||||
equals(e) {
|
||||
if ((WAS.Assert.optionalIsType(e, WAS.NodePath), !e)) return !1;
|
||||
if (this.#u.length !== e.#u.length) return !1;
|
||||
for (let t = 0; t < this.#u.length; ++t)
|
||||
if (!this.#u[t].equals(e.#u[t])) return !1;
|
||||
if (this.#_?.length !== e.#_?.length) return !1;
|
||||
for (let t = 0; t < this.#_?.length; ++t)
|
||||
if (!this.#_[t].equals(e.#_[t])) return !1;
|
||||
if (this.#A?.length !== e.#A?.length) return !1;
|
||||
for (let t = 0; t < this.#A?.length; ++t)
|
||||
if (!this.#A[t].equals(e.#A[t])) return !1;
|
||||
return this.#P === e.#P && this.#f === e.#f;
|
||||
}
|
||||
resolvedRangeInDocument(e) {
|
||||
let t = this.#C?.deref();
|
||||
if (t?.intersectsNode(e)) return t;
|
||||
if (this.#_ && this.#A) {
|
||||
let t = WAS.NodePath.#E(e, [...this.#u, ...this.#_]),
|
||||
n = WAS.NodePath.#E(e, [...this.#u, ...this.#A]);
|
||||
if (!t || !n) return null;
|
||||
let o = new Range();
|
||||
return (
|
||||
this.#P ? o.setStart(t, this.#P) : o.setStartBefore(t),
|
||||
this.#f ? o.setEnd(n, this.#f) : o.setEndAfter(n),
|
||||
(this.#C = new WeakRef(o)),
|
||||
o
|
||||
);
|
||||
}
|
||||
let n = WAS.NodePath.#E(e, this.#u);
|
||||
if (!n) return null;
|
||||
let o = Range.nodePath_fromNode(n);
|
||||
return ((this.#C = new WeakRef(o)), o);
|
||||
}
|
||||
static #E(e, t) {
|
||||
(WAS.Assert.isType(e, Node),
|
||||
WAS.Assert.isTrue(
|
||||
Document.nodePath_isDocument(e),
|
||||
"Must provide root document node in which to resolve this NodePath.",
|
||||
));
|
||||
let n = e;
|
||||
e: for (let e = 1; e < t.length && n; ++e) {
|
||||
let o = t[e],
|
||||
a = -1,
|
||||
i = null;
|
||||
const s = () => {
|
||||
n = i;
|
||||
let o = t.length > e ? t[e + 1] : null;
|
||||
return n &&
|
||||
HTMLIFrameElement.nodePath_isHTMLIFrameElement(n) &&
|
||||
o?.type === Node.DOCUMENT_NODE
|
||||
? (++e,
|
||||
void (n = HTMLIFrameElement.nodePath_contentWindowDocument(n)))
|
||||
: n && o?.type === Node.DOCUMENT_FRAGMENT_NODE
|
||||
? (++e, void (n = Element.nodePath_shadowRoot(n)))
|
||||
: void 0;
|
||||
};
|
||||
if (Element.nodePath_isElement(n)) {
|
||||
let o = [],
|
||||
a = e;
|
||||
for (; a < t.length; ++a) {
|
||||
let e = t[a];
|
||||
if (e.type !== Node.ELEMENT_NODE) break;
|
||||
o.push(e.toElementCSSSelector());
|
||||
}
|
||||
if (o.length) {
|
||||
const t = (e) => o.slice(0, o.length - e).join(" > ");
|
||||
let d = null;
|
||||
for (let r = 0; r < o.length; ++r)
|
||||
if (
|
||||
((d = Element.nodePath_querySelectorAll(n, t(r))),
|
||||
1 === d.length)
|
||||
) {
|
||||
((i = d.item(0)), (e = a - r - 1), s());
|
||||
continue e;
|
||||
}
|
||||
}
|
||||
}
|
||||
let d = 0;
|
||||
for (
|
||||
let e = Node.nodePath_firstChild(n);
|
||||
e;
|
||||
e = Node.nodePath_nextSibling(e)
|
||||
) {
|
||||
if (!Node.nodePath_includeWhenComputingSiblingIndex(e)) continue;
|
||||
let t = Number.MIN_VALUE,
|
||||
n = !0;
|
||||
const s = (e, o) => {
|
||||
e ? (t += o) : (n = !1);
|
||||
},
|
||||
r = (e, o) => {
|
||||
(1 !== e && (n = !1), (t += e * o));
|
||||
},
|
||||
h = (e) => {
|
||||
e && ((n = !1), (t -= e));
|
||||
};
|
||||
if (
|
||||
(s(Node.nodePath_nodeType(e) === o.type, WAS.NodePath.#h),
|
||||
Element.nodePath_isElement(e))
|
||||
) {
|
||||
(s(Element.nodePath_tagName(e) == o.tag, WAS.NodePath.#l),
|
||||
s(Element.nodePath_id(e) == o.id, WAS.NodePath.#c));
|
||||
let t = Element.nodePath_className(e)?.split(" ") ?? [],
|
||||
n = t.length,
|
||||
a = o.classes?.split(" ") ?? [],
|
||||
i = a.length;
|
||||
for (let e = 0; e < a.length; ++e) {
|
||||
let n = a[e],
|
||||
o = t.indexOf(n);
|
||||
-1 !== o && (t.splice(o, 1), a.splice(e, 1), --e);
|
||||
}
|
||||
(r(
|
||||
(n ? (n - t.length) / n : 1) * (i ? (i - a.length) / i : 1),
|
||||
WAS.NodePath.#N,
|
||||
),
|
||||
r(
|
||||
Node.nodePath_immediateInnerTextOfNode(e).nodePath_similarityTo(
|
||||
o.text,
|
||||
),
|
||||
WAS.NodePath.#m,
|
||||
));
|
||||
} else if (Text.nodePath_isText(e)) {
|
||||
let t = CharacterData.nodePath_data(e)?.nodePath_similarityTo(
|
||||
o.text,
|
||||
);
|
||||
r(t, WAS.NodePath.#m);
|
||||
}
|
||||
if ((h(Math.abs(d - o.index) * WAS.NodePath.#p), n)) {
|
||||
((a = Number.NaN), (i = e));
|
||||
break;
|
||||
}
|
||||
(t > a && ((a = t), (i = e)), ++d);
|
||||
}
|
||||
s();
|
||||
}
|
||||
return n;
|
||||
}
|
||||
}));
|
||||
0;
|
||||
@@ -0,0 +1,145 @@
|
||||
//# sourceURL=__InjectedScript_SavePageInliningOrDiscardingExternalResources.js
|
||||
/* Copyright (c) 2026 Apple Inc. All rights reserved. */
|
||||
function copyPage() {
|
||||
function e(e) {
|
||||
function t(e) {
|
||||
var t = document.createElement("a");
|
||||
return ((t.href = e), t);
|
||||
}
|
||||
function r(e) {
|
||||
var t = e.pathname.substring(1).split("/");
|
||||
return (t[t.length - 1] || t.pop(), t);
|
||||
}
|
||||
function n(e) {
|
||||
var t = r(e);
|
||||
return t.length ? t[t.length - 1] : null;
|
||||
}
|
||||
return n(t(e));
|
||||
}
|
||||
function t(t) {
|
||||
const r = /url\((.*?\/.*?)\)/gi;
|
||||
for (;;) {
|
||||
var n = r.exec(t);
|
||||
if (!n) break;
|
||||
t = t.replace(n[0], "url(" + e(n[1]) + ")");
|
||||
}
|
||||
return t;
|
||||
}
|
||||
function r(e) {
|
||||
function r(e, n) {
|
||||
if (e) {
|
||||
var i, o;
|
||||
try {
|
||||
i = e.rules;
|
||||
} catch (e) {
|
||||
i = null;
|
||||
}
|
||||
if (!i) {
|
||||
var u = e.ownerNode;
|
||||
if (!u) return;
|
||||
var c = u.parentNode;
|
||||
if (!c) return;
|
||||
var l = u.nextSibling;
|
||||
return (c.removeChild(u), r(e, n), void c.insertBefore(u, l));
|
||||
}
|
||||
for (var d = i.length, s = 0; s < d; ++s) {
|
||||
var m = i[s];
|
||||
m.type !== CSSRule.IMPORT_RULE
|
||||
? (o ||
|
||||
((o = document.createElement("style")),
|
||||
e.media &&
|
||||
e.media.length > 0 &&
|
||||
o.setAttribute("media", e.media.mediaText),
|
||||
n && n.media && o.setAttribute("media", n.media.mediaText),
|
||||
a.push(o)),
|
||||
o.appendChild(document.createTextNode(t(m.cssText) + "\n")))
|
||||
: r(m.styleSheet, m);
|
||||
}
|
||||
}
|
||||
}
|
||||
for (var n = e.styleSheets, a = [], i = n.length, o = 0; o < i; ++o)
|
||||
r(n[o]);
|
||||
return a;
|
||||
}
|
||||
function n(e, r) {
|
||||
for (var n = e.attributes, a = n.length, i = 0; i < a; ++i) {
|
||||
var o = n[i],
|
||||
u = o.name.toLowerCase();
|
||||
if ("on" !== u.substr(0, 2)) {
|
||||
var c = o.value;
|
||||
"style" === u && (c = t(c));
|
||||
try {
|
||||
r.setAttribute(o.name, c);
|
||||
} catch (e) {}
|
||||
}
|
||||
}
|
||||
}
|
||||
function a(e, t) {
|
||||
for (var r = e.childNodes, n = r.length, a = 0; a < n; ++a) {
|
||||
var o = i(r[a]);
|
||||
o && t.appendChild(o);
|
||||
}
|
||||
}
|
||||
function i(t) {
|
||||
if (!t) return t;
|
||||
if (t.nodeType === Node.TEXT_NODE) return document.createTextNode(t.data);
|
||||
if (t.nodeType !== Node.ELEMENT_NODE) return null;
|
||||
const c = new Set(["AUDIO", "OBJECT", "SCRIPT", "STYLE", "VIDEO"]);
|
||||
var l = t.tagName.toUpperCase();
|
||||
if (c.has(l)) return null;
|
||||
if ("LINK" === l && "STYLESHEET" === t.rel.toUpperCase()) return null;
|
||||
if ("META" === l && "CONTENT-TYPE" === t.httpEquiv.toUpperCase())
|
||||
return null;
|
||||
var d = document.createElement(t.tagName);
|
||||
if (
|
||||
(n(t, d),
|
||||
a(t, d),
|
||||
"IMG" === l || ("INPUT" === l && "IMAGE" === t.type.toUpperCase()))
|
||||
)
|
||||
return (
|
||||
(d.src = e(t.src)),
|
||||
d.setAttribute("width", t.width),
|
||||
d.setAttribute("height", t.height),
|
||||
d
|
||||
);
|
||||
if ("IFRAME" === l) {
|
||||
try {
|
||||
var s = i(t.contentDocument.documentElement);
|
||||
if (s) {
|
||||
var m = "iframe_" + u + ".html";
|
||||
((d.src = m),
|
||||
(s.dataset.originalSource = t.src),
|
||||
(o[m] = s.outerHTML),
|
||||
u++);
|
||||
}
|
||||
} catch (e) {
|
||||
((d.src = ""),
|
||||
d.appendChild(
|
||||
document.createTextNode(
|
||||
"Failed to copy <iframe>: " + e + ": " + e.stack,
|
||||
),
|
||||
));
|
||||
}
|
||||
return d;
|
||||
}
|
||||
if ("INPUT" === l) d.setAttribute("value", t.value);
|
||||
else if ("HEAD" === l) {
|
||||
for (var f = r(t.ownerDocument), h = f.length, p = 0; p < h; ++p)
|
||||
(d.appendChild(document.createTextNode("\n")), d.appendChild(f[p]));
|
||||
var v = document.createElement("meta");
|
||||
((v.httpEquiv = "Content-Type"),
|
||||
(v.content = "text/html; charset=UTF-8"),
|
||||
d.insertBefore(v, d.firstChild));
|
||||
}
|
||||
return d;
|
||||
}
|
||||
var o = {},
|
||||
u = 0,
|
||||
c = i(document.documentElement);
|
||||
return (
|
||||
(c.dataset.originSource = window.location),
|
||||
(o["main.html"] = c.outerHTML),
|
||||
o
|
||||
);
|
||||
}
|
||||
copyPage();
|
||||
@@ -9,11 +9,16 @@ This repository contains two dumps of Safari's internal JavaScript files:
|
||||
- Extraction Date: 16/01/2026
|
||||
- Extraction Method: dyld_shared_cache
|
||||
|
||||
### Safari 26.2 (Latest)
|
||||
### Safari 26.2
|
||||
- Location: [`26.2/`](26.2/)
|
||||
- Extraction Date: 17/01/2026
|
||||
- Extraction Method: dyld_shared_cache
|
||||
|
||||
### Safari 27.0 (Latest)
|
||||
- Location: [`27.0/`](27.0/)
|
||||
- Extraction Date: 17/09/2026
|
||||
- Extraction Method: dyld_shared_cache
|
||||
|
||||
**Credit:** Inspired by [safari-readability](https://github.com/dm-zharov/safari-readability) by [dm-zharov](https://github.com/dm-zharov)
|
||||
|
||||
## Disclaimer:
|
||||
|
||||
Reference in New Issue
Block a user