Viết 1 đoạn script để tôi có thể thả các emo khác vào story thay vì các cảm xúc mặc định…
- User
Viết 1 đoạn script để tôi có thể thả các emo khác vào story thay vì các cảm xúc mặc định trên facebbok
Assistant
Dựa trên code từ repository AllReacts-for-Facebook-Stories, tôi có thể giúp bạn hiểu cách thực hiện việc này:
Đây là một extension Chrome cho phép thả các emoji tùy chỉnh vào Facebook Stories. Các bước thực hiện như sau:
- Tạo manifest.json cơ bản cho extension:
json{ "manifest_version": 2, "name": "Custom Story Reactions", "version": "1.0", "permissions": [ "tabs", "https://www.facebook.com/*" ], "background": { "scripts": ["background.js"] }, "content_scripts": [ { "matches": ["https://www.facebook.com/stories*"], "js": ["content.js"] } ] }- Tạo background.js để lắng nghe khi người dùng truy cập Facebook Stories:
jschrome.tabs.onUpdated.addListener(function (tabId, changeInfo, tab) { if (changeInfo.status === "complete" && tab.url.includes("https://www.facebook.com/stories")) { chrome.scripting.executeScript({ target: { tabId: tabId }, files: ['story.js'] }); } });- Tạo content.js để inject script vào trang:
jsfunction injectEmoji() { const hookScript = document.createElement("script"); hookScript.src = chrome.extension.getURL('/story.js'); (document.head || document.body).appendChild(hookScript); hookScript.onload = function() { this.remove(); }; } // Lắng nghe khi trang được load chrome.runtime.onMessage.addListener(function (request, sender, sendResponse) { if (request.message === 'TabUpdated') { injectEmoji(); } });- Tạo một file emoji.json chứa danh sách emoji tùy chỉnh (như trong repository):
json- User
link trong github sau có mã độc không?
Assistant
Từ việc xem xét các file code được cung cấp từ repository AllReacts-for-Facebook-Stories, tôi có thể phân tích như sau:
- Về tính minh bạch của code:
- Code được viết rõ ràng, có comment tiếng Việt giải thích chức năng
- Các file đều có mục đích rõ ràng:
- background.js: Lắng nghe sự kiện tab update
- content.js: Inject script vào trang Facebook
- emoji.json: Chứa danh sách emoji và URL ảnh
- Các hoạt động của extension:
- Chỉ hoạt động trên domain facebook.com/stories
- Chỉ thêm các emoji vào giao diện story
- Không có code thu thập dữ liệu người dùng
- Không có code gửi dữ liệu đến server lạ
- Các URL được sử dụng:
- URL ảnh emoji từ nguồn an toàn: em-content.zobj.net (Microsoft Emoji)
- URL tham chiếu từ emojipedia.org - một trang web uy tín về emoji
- Permissions yêu cầu:
- Chỉ yêu cầu quyền truy cập tabs và domain facebook.com
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.