Skip to content

Commit

Permalink
Merge branch 'master' into 444-websocket-streaming
Browse files Browse the repository at this point in the history
  • Loading branch information
rc10house authored Aug 21, 2024
2 parents 579d05f + 4eec2ff commit 30f5dfb
Show file tree
Hide file tree
Showing 22 changed files with 411 additions and 196 deletions.
43 changes: 43 additions & 0 deletions build/UserALEWebExtension/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -635,6 +635,8 @@ function packageLog(e, detailFcn) {
sessionId: config$1.sessionId,
httpSessionId: config$1.httpSessionId,
browserSessionId: config$1.browserSessionId,
attributes: buildAttrs(e),
style: buildCSS(e),
};
for (const func of Object.values(cbHandlers)) {
if (typeof func === "function") {
Expand Down Expand Up @@ -871,6 +873,47 @@ function detectBrowser() {
version: browserInfo ? browserInfo.version : "",
};
}
/**
* Builds an object containing attributes of an element.
* Attempts to parse all attribute values as JSON text.
* @param {Event} e Event from which the target element's attributes should be extracted.
* @return {Record<string, any>} Object with element attributes as key-value pairs.
*/
function buildAttrs(e) {
const attributes = {};
const attributeBlackList = ["style"];
if (e.target && e.target instanceof Element) {
for (const attr of e.target.attributes) {
if (attributeBlackList.includes(attr.name))
continue;
let val = attr.value;
try {
val = JSON.parse(val);
}
catch (error) {
// Ignore parsing errors, fallback to raw string value
}
attributes[attr.name] = val;
}
}
return attributes;
}
/**
* Builds an object containing all CSS properties of an element.
* @param {Event} e Event from which the target element's properties should be extracted.
* @return {Record<string, string>} Object with all CSS properties as key-value pairs.
*/
function buildCSS(e) {
const properties = {};
if (e.target && e.target instanceof HTMLElement) {
const styleObj = e.target.style;
for (let i = 0; i < styleObj.length; i++) {
const prop = styleObj[i];
properties[prop] = styleObj.getPropertyValue(prop);
}
}
return properties;
}

/*
* Licensed to the Apache Software Foundation (ASF) under one or more
Expand Down
File renamed without changes.
43 changes: 43 additions & 0 deletions build/UserALEWebExtension/content.js
Original file line number Diff line number Diff line change
Expand Up @@ -582,6 +582,8 @@ function packageLog(e, detailFcn) {
sessionId: config$1.sessionId,
httpSessionId: config$1.httpSessionId,
browserSessionId: config$1.browserSessionId,
attributes: buildAttrs(e),
style: buildCSS(e),
};
for (const func of Object.values(cbHandlers)) {
if (typeof func === "function") {
Expand Down Expand Up @@ -818,6 +820,47 @@ function detectBrowser() {
version: browserInfo ? browserInfo.version : "",
};
}
/**
* Builds an object containing attributes of an element.
* Attempts to parse all attribute values as JSON text.
* @param {Event} e Event from which the target element's attributes should be extracted.
* @return {Record<string, any>} Object with element attributes as key-value pairs.
*/
function buildAttrs(e) {
const attributes = {};
const attributeBlackList = ["style"];
if (e.target && e.target instanceof Element) {
for (const attr of e.target.attributes) {
if (attributeBlackList.includes(attr.name))
continue;
let val = attr.value;
try {
val = JSON.parse(val);
}
catch (error) {
// Ignore parsing errors, fallback to raw string value
}
attributes[attr.name] = val;
}
}
return attributes;
}
/**
* Builds an object containing all CSS properties of an element.
* @param {Event} e Event from which the target element's properties should be extracted.
* @return {Record<string, string>} Object with all CSS properties as key-value pairs.
*/
function buildCSS(e) {
const properties = {};
if (e.target && e.target instanceof HTMLElement) {
const styleObj = e.target.style;
for (let i = 0; i < styleObj.length; i++) {
const prop = styleObj[i];
properties[prop] = styleObj.getPropertyValue(prop);
}
}
return properties;
}

/*
* Licensed to the Apache Software Foundation (ASF) under one or more
Expand Down
4 changes: 2 additions & 2 deletions build/UserALEWebExtension/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@
}
],
"options_ui": {
"page": "optionsPage.html"
"page": "options.html"
},
"browser_action": {
"default_popup": "optionsPage.html"
"default_popup": "browserAction.html"
}
}
57 changes: 57 additions & 0 deletions build/UserALEWebExtension/options.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
<!--
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
-->

<!doctype html>
<html>
<head>
<title>User ALE Web Extension - Options</title>
<script src="options.js"></script>
<meta charset="utf-8" />
</head>
<body>
<h1>Logging Options</h1>
<form name="optionsForm" id="optionsForm">
<label>Logging Endpoint URL:</label>
<input name="url" id="url" />
<br />

<label>User:</label>
<input name="userId" id="user" />
<br />

<label>Password:</label>
<input name="password" type="password" id="password" />
<br />

<label>Tool Name:</label>
<input name="toolName" id="tool" />
<br />

<label>Tool Version:</label>
<input name="toolVersion" id="toolVersion" />
<br />

<label>URL whitelist regex:</label>
<input name="filter" id="filter" />
<br />

<div align="right">
<button type="submit" id="submitOptions">Save Changes</button>
</div>
</form>
</body>
</html>
48 changes: 47 additions & 1 deletion build/UserALEWebExtension/options.js
Original file line number Diff line number Diff line change
Expand Up @@ -582,6 +582,8 @@ function packageLog(e, detailFcn) {
sessionId: config$1.sessionId,
httpSessionId: config$1.httpSessionId,
browserSessionId: config$1.browserSessionId,
attributes: buildAttrs(e),
style: buildCSS(e),
};
for (const func of Object.values(cbHandlers)) {
if (typeof func === "function") {
Expand Down Expand Up @@ -818,6 +820,47 @@ function detectBrowser() {
version: browserInfo ? browserInfo.version : "",
};
}
/**
* Builds an object containing attributes of an element.
* Attempts to parse all attribute values as JSON text.
* @param {Event} e Event from which the target element's attributes should be extracted.
* @return {Record<string, any>} Object with element attributes as key-value pairs.
*/
function buildAttrs(e) {
const attributes = {};
const attributeBlackList = ["style"];
if (e.target && e.target instanceof Element) {
for (const attr of e.target.attributes) {
if (attributeBlackList.includes(attr.name))
continue;
let val = attr.value;
try {
val = JSON.parse(val);
}
catch (error) {
// Ignore parsing errors, fallback to raw string value
}
attributes[attr.name] = val;
}
}
return attributes;
}
/**
* Builds an object containing all CSS properties of an element.
* @param {Event} e Event from which the target element's properties should be extracted.
* @return {Record<string, string>} Object with all CSS properties as key-value pairs.
*/
function buildCSS(e) {
const properties = {};
if (e.target && e.target instanceof HTMLElement) {
const styleObj = e.target.style;
for (let i = 0; i < styleObj.length; i++) {
const prop = styleObj[i];
properties[prop] = styleObj.getPropertyValue(prop);
}
}
return properties;
}

/*
* Licensed to the Apache Software Foundation (ASF) under one or more
Expand Down Expand Up @@ -1274,7 +1317,10 @@ function getConfig() {
payload.pluginConfig.urlWhitelist;
});
document.getElementById("optionsForm").addEventListener("submit", setConfig);
document.getElementById("issueForm").addEventListener("submit", reportIssue);
const issueForm = document.getElementById("issueForm");
if (issueForm instanceof HTMLElement) {
issueForm.addEventListener("submit", reportIssue);
}
}
function reportIssue() {
browser.runtime.sendMessage({
Expand Down
13 changes: 13 additions & 0 deletions build/packageLogs.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,3 +113,16 @@ export declare function detectBrowser(): {
browser: string;
version: string | null;
};
/**
* Builds an object containing attributes of an element.
* Attempts to parse all attribute values as JSON text.
* @param {Event} e Event from which the target element's attributes should be extracted.
* @return {Record<string, any>} Object with element attributes as key-value pairs.
*/
export declare function buildAttrs(e: Event): Record<string, any>;
/**
* Builds an object containing all CSS properties of an element.
* @param {Event} e Event from which the target element's properties should be extracted.
* @return {Record<string, string>} Object with all CSS properties as key-value pairs.
*/
export declare function buildCSS(e: Event): Record<string, string>;
43 changes: 43 additions & 0 deletions build/userale-2.4.0.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion build/userale-2.4.0.js.map

Large diffs are not rendered by default.

Loading

0 comments on commit 30f5dfb

Please sign in to comment.