Skip to content

Commit 959c9b9

Browse files
committed
chore: update textual descriptions in code
1 parent e7658c3 commit 959c9b9

File tree

11 files changed

+45
-42
lines changed

11 files changed

+45
-42
lines changed

README.md

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# APITable Url to Image Converter
1+
# AITable Url to Image Converter
22

33
<p align='center'>
44
<image src="logo/logo-48.png" />
@@ -14,7 +14,7 @@
1414
<a href="README_CN.md">简体中文</a>
1515
</p>
1616

17-
This is a browser extension that extracts images from URLs and uploads them to APITable.
17+
This is a browser extension that extracts images from URLs and uploads them to AITable or APITble.
1818

1919
- ✨ You can extract images from URL addresses and save them to the "Attachment" field.
2020
- ✨ Supports processing multiple URLs separated by commas (in a single cell), enabling multiple attachments to be saved in the same cell.
@@ -47,33 +47,36 @@ Before using the extension, follow these steps to set your API access credential
4747
1. Open the extension's options page.
4848
If you can't find the options page, right-click the extension icon and click button "Options".
4949

50-
2. In the options page, enter your APITable API Token and API Host information.
51-
If you don't have an API Token yet, you can register and obtain one on the [APITable website](https://apitable.com/).
50+
2. In the options page, enter your AITable API Token and API Host information.
51+
If you don't have an API Token yet, you can register and obtain one on the [AITable website](https://aitable.ai/).
5252

5353
3. Save the settings and return to the extension's pop-up page.
5454

5555
## Usage
5656

57-
1. Visit [APITable.com](https://apitable.com/) and open the datasheet to be processed.
57+
1. Visit [aitable.ai](https://aitable.ai/) and open the datasheet to be processed.
5858

5959
2. Click the icon of this extension to bring up the operation interface. Select which field to read the URL information from and specify which attachment field to save the image data collected from the URL.
6060

6161
> Tip 1: URLs must be stored in fields of the following three types: "Single Line Text", "Long Text", and "URL". Other field types will be filtered out and will not appear in the drop-down selection box.
6262
63-
> Tip 2: You must first open the APITable.com datasheet link and then start the browser extension. Otherwise, the extension will be unable to get the field list of the datasheet.
63+
> Tip 2: You must first open the aitable.ai datasheet link and then start the browser extension. Otherwise, the extension will be unable to get the field list of the datasheet.
6464
6565
3. After confirming that everything is correct, click the "conver" button, and the extension will begin extracting images and saving to "attachments" field in the background (extension service worker).
6666

67-
> Tip: Since this is done in the background, you can close the extension popup window and even the currently active APITable webpage after starting the process. The image extraction and attachment conversion will continue to function normally (but you cannot close the browser...).
67+
> Tip: Since this is done in the background, you can close the extension popup window and even the currently active AITable webpage after starting the process. The image extraction and attachment conversion will continue to function normally (but you cannot close the browser...).
6868
6969
## FAQ
7070

71-
**Q: Can other file formats be extracted and saved to APITable?**
71+
**Q: Can other file formats be extracted and saved to AITable?**
7272
A: Yes. As long as the URL points to a file that can be directly downloaded by the browser, whether it's a PDF or an mp4, it can be converted using this extension.
7373

7474
**Q: Some URLs fail to be converted successfully. How can I check the logs or debug?**
7575
A: Right-click on the extension pop-up window and select "Inspect" from the menu to view the log messages through the console. Or open the console of the service worker to view the background running logs.
7676

77+
**Q: What's the relationship between AITable and APITable?**
78+
A: APITable is the community edition of AITable. Extension "Url to Image Converter" works for both of them.
79+
7780
## Contribution
7881

7982
Contributions in the form of code, reporting issues, and suggestions are welcome.

README_CN.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# APITable Url to Image Converter
1+
# AITable Url to Image Converter
22

33
<p align='center'>
44
<image src="logo/logo-48.png" />
@@ -14,9 +14,9 @@
1414
<a href="README_CN.md">简体中文</a>
1515
</p>
1616

17-
以浏览器扩展程序的形式,实现从URL中提取图像并将其上传到APITable的能力
17+
以浏览器扩展程序的形式,实现从URL中提取图像并将其上传到 AITable 的能力
1818

19-
- ✨ 支持 APITable/维格表的整表读取,将URL地址对应的文件下载并转存至“附件”字段当中;
19+
- ✨ 支持 AITable/维格表的整表读取,将URL地址对应的文件下载并转存至“附件”字段当中;
2020
- ✨ 支持以“,”分隔的多个URL文本处理(单个单元格内),实现多附件转存至同一单元格内;
2121
- ✨ 对入门级开发者友好,使用基础HTML,JavaScript,CSS开发而成,无需掌握React、Vue等框架
2222

@@ -47,28 +47,28 @@
4747
1. 打开扩展程序的选项页面。
4848
如果您无法找到选项页面,可以右键点击扩展程序的图标,然后选择“选项”。
4949

50-
2. 在 options 页面中,输入您的 APITable API Token 和 API Host 信息。
51-
如果您还没有 APITable API Token,可以在 [APITable 官网](https://apitable.com/) 注册并获取。
50+
2. 在 options 页面中,输入您的 AITable API Token 和 API Host 信息。
51+
如果您还没有 AITable API Token,可以在 [AITable 官网](https://aitable.ai/) 注册并获取。
5252

5353
3. 保存设置并返回扩展程序的主页面。
5454

5555
## 使用步骤
5656

57-
1. 访问 APITable.com, 打开待处理的表格。
57+
1. 访问 aitable.ai, 打开待处理的表格。
5858

5959
2. 在浏览器扩展程序的区域,单击本扩展程序的图标,弹出操作界面。请选择从哪个字段里读取 URL 信息,并且指定从 URL 采集的图片数据保存至哪个附件字段中。
6060

6161
> 提示1:URL必须要存储在“单行文本”,“多行文本”,“网址”这三种字段类型之中,其他类型字段会被过滤,不会出现在下拉选择框中.
62-
> 提示2:必须要先打开 APITable.com 的表格链接,再启动浏览器扩展程序。否则程序无法抓取到表格的字段信息。
62+
> 提示2:必须要先打开 aitable.ai 的表格链接,再启动浏览器扩展程序。否则程序无法抓取到表格的字段信息。
6363
6464
3. 确认无误后,点击按钮“conver”,扩展程序将会在后台(extension service worker)开始图片采集和转存附件的操作。
6565

66-
> 提示:由于是在后台处理。因此执行开始后,你可以关闭程序弹窗,甚至关闭当前激活中的 APITable 网页,图片采集和转存附件工作仍会正常运作。(但不能关闭浏览器...)
66+
> 提示:由于是在后台处理。因此执行开始后,你可以关闭程序弹窗,甚至关闭当前激活中的 AITable 网页,图片采集和转存附件工作仍会正常运作。(但不能关闭浏览器...)
6767
6868

6969
## 常见问题
7070

71-
**Q:可以采集其他格式的文件并转存至 APITable/维格表吗?**
71+
**Q:可以采集其他格式的文件并转存至 AITable/维格表吗?**
7272
A:可以的。只要 URL 指向的是一个可被浏览器直接下载的文件,不管是PDF还是mp4,都可以通过本扩展程序进行转存。
7373

7474
**Q:有一些url无法成功转存成功,我应该如何查看日志或者调试?**

apitable-url-to-image.zip

781 KB
Binary file not shown.

apitable-url-to-image.zip.old

625 KB
Binary file not shown.

manifest.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
{
22
"manifest_version": 3,
3-
"name": "APITable Url to Image Converter",
4-
"description": "An extension designed to extract images from URLs and upload them to APITable.",
5-
"version": "0.1.2",
3+
"name": "AITable Url to Image Converter",
4+
"description": "An extension designed to extract images from URLs and upload them to AITable.",
5+
"version": "0.1.3",
66
"icons": {
77
"16": "logo/logo-16.png",
88
"48": "logo/logo-48.png",

popup/popup.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<html lang="en">
33

44
<head>
5-
<title>APITable Url to Image Converter:Popup</title>
5+
<title>AITable Url to Image Converter:Popup</title>
66
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />
77
<link rel="stylesheet" href="../assets/custom-bootstrap-magic.css" />
88
<link rel="stylesheet" href="popup.css" />

popup/popup.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// Where we will expose all the data we retrieve from storage.sync.
2-
const storageCache = { apiToken: '', apiHost: 'https://apitable.com' };
2+
const storageCache = { apiToken: '', apiHost: 'https://aitable.ai' };
33
// Asynchronously retrieve data from storage.sync, then cache it.
44
const initStorageCache = chrome.storage.sync.get().then((items) => {
55
// Copy the data retrieved from storage into storageCache.
@@ -27,7 +27,7 @@ async function getDatasheetParamsFromURL() {
2727
popupData.datasheetId = match[1];
2828
popupData.viewId = match[2];
2929
} else {
30-
throw new Error("Please open a datasheet view in APITable Workbench.");
30+
throw new Error("Please open a datasheet view in AITable Workbench.");
3131
}
3232
}
3333

@@ -95,7 +95,7 @@ async function convert() {
9595
console.log(response);
9696

9797
if (response.success !== undefined) {
98-
if (response.success == true) {
98+
if (response.success === true) {
9999
showMsg("Conversion completed successfully.", "alert-success");
100100
} else {
101101
showMsg("Error: "+ JSON.stringify(response.message), "alert-danger");
@@ -113,7 +113,7 @@ async function convert() {
113113
function showMsg(msg, type) {
114114
const msgEl = document.querySelector('#alertBox');
115115
msgEl.textContent = msg;
116-
msgEl.classList.add(type ? type : "alert-primary");
116+
msgEl.classList.add(type || "alert-primary");
117117
msgEl.style.display = "block";
118118
}
119119

service-worker-utils.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,11 @@ function startsWithHttpOrHttps(urlStr) {
2323
}
2424

2525
/**
26-
* Checks if a URL string matches the APITable attachment format
26+
* Checks if a URL string matches the AITable attachment format
2727
* @param {String} urlStr - The URL string to be validated
2828
* @returns {Boolean} - The result of the regular expression test
2929
*/
30-
function isAPITableAttachmentFormat(urlStr) {
30+
function isAITableAttachmentFormat(urlStr) {
3131
// Regular expression pattern to match URLs in the format "filename (http|https://url)"
3232
let pattern = /.+\s\((http|https):\/\/.+?\.(jpg|gif|jpeg|png)\)$/i;
3333
return pattern.test(urlStr);
@@ -57,7 +57,7 @@ function filterValidUrls(record, urlFieldId) {
5757
let fieldValue = record.fields[urlFieldId];
5858

5959
// If the field value is an empty string, return null
60-
if (fieldValue === "") {
60+
if (typeof fieldValue !== "string" || fieldValue.trim() === "") {
6161
return null;
6262
}
6363

@@ -76,10 +76,10 @@ function filterValidUrls(record, urlFieldId) {
7676
if (startsWithHttpOrHttps(valStr)) {
7777
result.push(getFileUrlObject(valStr));
7878
}
79-
// If the value is in the format of an APITable attachment field converted to a string, add it to the result array
80-
else if (isAPITableAttachmentFormat(valStr)) {
79+
// If the value is in the format of an AITable attachment field converted to a string, add it to the result array
80+
else if (isAITableAttachmentFormat(valStr)) {
8181
let tmp = valStr.split(" (");
82-
console.log("analyzing APITable Format URL", tmp);
82+
console.log("analyzing AITable Format URL", tmp);
8383
let fileObj = {
8484
fileName: tmp[0].trim(),
8585
url: tmp[1].substr(0, tmp[1].length - 1),
@@ -88,13 +88,13 @@ function filterValidUrls(record, urlFieldId) {
8888
}
8989
});
9090
}
91-
// If there's only one url, check if it's a valid image url or an APITable attachment field converted to a string
91+
// If there's only one url, check if it's a valid image url or an AITable attachment field converted to a string
9292
else {
9393
if (startsWithHttpOrHttps(fieldValue)) {
9494
result.push(getFileUrlObject(fieldValue));
95-
} else if (isAPITableAttachmentFormat(fieldValue)) {
95+
} else if (isAITableAttachmentFormat(fieldValue)) {
9696
let tmp = fieldValue.split(" (");
97-
console.log("analyzing APITable Format URL", tmp);
97+
console.log("analyzing AITable Format URL", tmp);
9898
let fileObj = {
9999
fileName: tmp[0].trim(),
100100
url: tmp[1].substr(0, tmp[1].length - 1),

service-worker.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ const initStorageCache = chrome.storage.sync.get().then((items) => {
2424
Object.assign(storageCache, items);
2525
});
2626

27-
// fetch image data from url, convert to blob data, and upload to APITable as attachment with API
27+
// fetch image data from url, convert to blob data, and upload to AITable as attachment with API
2828
async function convertUrltoImage(eventData) {
2929
const params = {
3030
datasheetId: eventData.popupData.datasheetId,
@@ -48,12 +48,12 @@ async function convertUrltoImage(eventData) {
4848
// get the urls from the url field
4949
const imageUrls = filterValidUrls(record, params.urlFieldId)
5050

51-
console.debug(`Processing ${imageUrls.length} urls`, imageUrls);
52-
5351
if (!Array.isArray(imageUrls) || imageUrls.length == 0) {
5452
continue;
5553
}
5654

55+
console.debug(`Processing ${imageUrls.length} urls`, imageUrls);
56+
5757
const uploader = new ImageUploader(params.datasheetId, params.viewId, storageCache.apiHost, storageCache.apiToken);
5858

5959
const result = await uploader.fetch(imageUrls)
@@ -124,7 +124,7 @@ chrome.runtime.onMessage.addListener(function (
124124
eventMsg
125125
);
126126

127-
const eventData = Object.assign({}, eventMsg.data);
127+
const eventData = { ...eventMsg.data};
128128

129129
initStorageCache.then(() => {
130130
if (eventMsg.event == "convertToImage") {

settings/settings.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
<link rel="stylesheet" href="../assets/custom-bootstrap-magic.css" />
88
<link rel="stylesheet" href="settings.css" />
9-
<title>APITable Url to Image Converter:Settings</title>
9+
<title>AITable Url to Image Converter:Settings</title>
1010
</head>
1111
<body>
1212

@@ -24,7 +24,7 @@
2424
<div class="form-group">
2525
<label for="inputUrlField"> API Host </label>
2626
<input class="form-control" id="inputHostField" />
27-
<small id="hostHelp" class="form-text text-muted">Tips: The APITable api host </small>
27+
<small id="hostHelp" class="form-text text-muted">Tips: The AITable api host </small>
2828
</div>
2929

3030
<div class="form-group text-right pt-2 mb-0">

0 commit comments

Comments
 (0)