我正在尝试创建我的第一个Google Chrome扩展程序。下面解释了我想要扩展名的内容,然后是我的问题。
我想创建一个与Linkedin一起运行的扩展程序。用户可以在扩展名中输入参数(带有html),然后将此输入以及用户的所有过去输入保存到列表中。然后,可以将其与linkedin连接(如果具有扩展名)进行比较,并且具有相同输入的连接将显示在扩展名中。
我现在想要做的是在扩展名中显示用户列表。我研究了存储,主要是“ chrome.storage.sync.set”,但是我不确定它是否适合我的情况(因为我刚起步,所以我了解得很少)。我想他可能必须登录,这样才能为每个用户关联一个列表。
我的popup.html看起来像这样:
<!DOCTYPE html>
<html>
<head>
<style>
button {
height: 30px;
width: 30px;
outline: none;
}
</style>
</head>
<body>
Job: <input type="text" name="Job" value="FB"><br>
<input type="submit" value="Submit">
<script src="popup.js"></script>
</body>
</html>
我的background.js是这样的:
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
'use strict';
chrome.runtime.onInstalled.addListener(function() {
chrome.storage.sync.set({color: '#3aa757'}, function() {
console.log('The color is green.');
});
chrome.storage.sync.set({ "yourBody": "myBody" }, function() {
console.log('Body has been saved');
});
chrome.declarativeContent.onPageChanged.removeRules(undefined, function() {
chrome.declarativeContent.onPageChanged.addRules([{
conditions: [new chrome.declarativeContent.PageStateMatcher({
pageUrl: { urlContains: 'linkedin' },
})
],
actions: [new chrome.declarativeContent.ShowPageAction()]
}]);
});
});
也许我只是想做不到(userMe可以将扩展名中输入的数据与他/她连接中的任何用户进行比较),在这种情况下,如果有人可以告诉我是否可以不是。
欢呼声