Chrome Dify Chatbot Plug-in (#1378)
Co-authored-by: luowei <glpat-EjySCyNjWiLqAED-YmwM> Co-authored-by: crazywoola <427733928@qq.com>pull/1387/head
|
After Width: | Height: | Size: 15 KiB |
|
After Width: | Height: | Size: 8.0 KiB |
|
After Width: | Height: | Size: 11 KiB |
|
After Width: | Height: | Size: 13 KiB |
|
After Width: | Height: | Size: 31 KiB |
|
After Width: | Height: | Size: 73 KiB |
|
After Width: | Height: | Size: 96 KiB |
|
After Width: | Height: | Size: 55 KiB |
|
After Width: | Height: | Size: 85 KiB |
@ -0,0 +1,29 @@
|
|||||||
|
{
|
||||||
|
"manifest_version": 3,
|
||||||
|
"name": "Dify Chatbot",
|
||||||
|
"version": "1.3",
|
||||||
|
"description": "This is a chrome extension to inject a dify chatbot on any pages",
|
||||||
|
"content_scripts": [
|
||||||
|
{
|
||||||
|
"matches": ["<all_urls>"],
|
||||||
|
"js": ["content.js"]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"permissions": ["webRequest", "storage"],
|
||||||
|
"action": {
|
||||||
|
"default_popup": "options.html",
|
||||||
|
"default_icon": {
|
||||||
|
"16": "images/16.png",
|
||||||
|
"32": "images/32.png",
|
||||||
|
"48": "images/48.png",
|
||||||
|
"128": "images/128.png"
|
||||||
|
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"icons": {
|
||||||
|
"16": "images/16.png",
|
||||||
|
"32": "images/32.png",
|
||||||
|
"48": "images/48.png",
|
||||||
|
"128": "images/128.png"
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,56 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
|
||||||
|
<head>
|
||||||
|
<title>Dify Chatbot Extension</title>
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<link href="https://cdn.jsdelivr.net/npm/tailwindcss@2.2.19/dist/tailwind.min.css" rel="stylesheet">
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body class="bg-gray-100 py-8 px-4 w-96">
|
||||||
|
<div class="max-w-md mx-auto bg-white shadow-md rounded-lg p-4">
|
||||||
|
<h2 class="text-2xl font-semibold mb-4">Dify Chatbot Extension</h2>
|
||||||
|
<form>
|
||||||
|
<div class="mb-4 flex items-center">
|
||||||
|
<div class="w-1/4">
|
||||||
|
<label for="base-url" class="block font-semibold text-gray-700">Base URL</label>
|
||||||
|
</div>
|
||||||
|
<div class="w-3/4">
|
||||||
|
<input type="text" id="base-url" name="base-url" value=""
|
||||||
|
class="w-full border border-gray-300 rounded px-3 py-2 focus:outline-none focus:border-blue-400"
|
||||||
|
placeholder="https://udify.app">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="mb-4 flex items-center">
|
||||||
|
<div class="w-1/4">
|
||||||
|
<label for="token" class="block font-semibold text-gray-700">Token</label>
|
||||||
|
</div>
|
||||||
|
<div class="w-3/4">
|
||||||
|
<input type="text" id="token" name="token" value=""
|
||||||
|
class="w-full border border-gray-300 rounded px-3 py-2 focus:outline-none focus:border-blue-400"
|
||||||
|
placeholder="Application Embedded Token">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="mb-4 flex items-center">
|
||||||
|
<div class="w-1/4"></div>
|
||||||
|
<div class="w-3/4">
|
||||||
|
<span id="error-tip" class="text-red-600"></span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="mb-4 flex items-center">
|
||||||
|
<div class="w-1/4"></div>
|
||||||
|
<div class="w-3/4">
|
||||||
|
<button id="save-button"
|
||||||
|
class="bg-blue-500 text-white py-2 px-4 rounded hover:bg-blue-600 focus:outline-none focus:bg-blue-600">Save</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<script src="options.js"></script>
|
||||||
|
</body>
|
||||||
|
|
||||||
|
</html>
|
||||||
@ -0,0 +1,39 @@
|
|||||||
|
|
||||||
|
document.getElementById('save-button').addEventListener('click', function (e) {
|
||||||
|
e.preventDefault();
|
||||||
|
var baseUrl = document.getElementById('base-url').value;
|
||||||
|
var token = document.getElementById('token').value;
|
||||||
|
var errorTip = document.getElementById('error-tip');
|
||||||
|
|
||||||
|
if (baseUrl.trim() === "" || token.trim() === "") {
|
||||||
|
if (baseUrl.trim() === "") {
|
||||||
|
errorTip.textContent = "Base URL cannot be empty.";
|
||||||
|
} else {
|
||||||
|
errorTip.textContent = "Token cannot be empty.";
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
errorTip.textContent = "";
|
||||||
|
|
||||||
|
chrome.storage.sync.set({
|
||||||
|
'baseUrl': baseUrl,
|
||||||
|
'token': token
|
||||||
|
}, function () {
|
||||||
|
alert('Save Success!');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
// Load parameters from chrome.storage when the page loads
|
||||||
|
chrome.storage.sync.get(['baseUrl', 'token'], function (result) {
|
||||||
|
const baseUrlInput = document.getElementById('base-url');
|
||||||
|
const tokenInput = document.getElementById('token');
|
||||||
|
|
||||||
|
if (result.baseUrl) {
|
||||||
|
baseUrlInput.value = result.baseUrl;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (result.token) {
|
||||||
|
tokenInput.value = result.token;
|
||||||
|
}
|
||||||
|
});
|
||||||