diff --git a/action/popup.js b/action/popup.js
index c597f58..5bbe257 100644
--- a/action/popup.js
+++ b/action/popup.js
@@ -24,4 +24,4 @@ var pageInfo = {};
window.open(chrome.extension.getURL('/options/search.html'));
}
- document.getElementById('cz').src=`http://www.jsearch.site/home/?p=popup&id=${chrome.runtime.id}`;
\ No newline at end of file
+ //document.getElementById('cz').src=`http://www.jsearch.site/home/?p=popup&id=${chrome.runtime.id}`;
\ No newline at end of file
diff --git a/app.json b/app.json
index 5d81be2..c713c46 100644
--- a/app.json
+++ b/app.json
@@ -1,5 +1,5 @@
{
- "version": "1.2.1",
- "broadcast":"新版本推送|v1.2.1 带来【搜索结果自然排序】【搜索结果来源标识】【搜索历史】三大更新, 查看详情 |0",
+ "version": "1.2.2",
+ "broadcast":"发现新版本v1.2.2, 查看详情 |0",
"broadcast2":"通知|欢迎使用 jSearch(聚搜) !!!觉得不错就给个 Star 吧!|0"
}
\ No newline at end of file
diff --git a/bg/main.js b/bg/main.js
index daa960e..29bf644 100644
--- a/bg/main.js
+++ b/bg/main.js
@@ -58,19 +58,21 @@ chrome.runtime.onMessage.addListener(function(request, sender, sendResponse){
});
//监听 storage变化
-chrome.storage.sync.onChanged.addListener(function(changes){
+chrome.storage.onChanged.addListener(function(changes ,type){
- //console.log(changes);
+ //console.log(type,changes);
+ if(type == 'sync'){
- //广播搜索历史到各个页面
- if(changes.searchHistory){
- broadcast({dataType:'searchHistory',data:changes.searchHistory.newValue});
- }
+ //广播搜索历史到各个页面
+ if(changes.searchHistory){
+ broadcast({dataType:'searchHistory',data:changes.searchHistory.newValue});
+ }
- //更新后台运行时设置数据
- if(changes.settings){
- RunTime = changes.settings.newValue.BG;
- broadcast({dataType:'settings',data:changes.settings.newValue});
+ //更新后台 运行时数据
+ if(changes.settings){
+ RunTime = changes.settings.newValue.BG;
+ broadcast({dataType:'settings',data:changes.settings.newValue});
+ }
}
});
@@ -81,12 +83,20 @@ chrome.storage.sync.onChanged.addListener(function(changes){
function broadcast(data){
chrome.tabs.getAllInWindow(function(tabs){
for(let i in tabs){
- chrome.tabs.sendMessage(
- tabs[i].id,
- data,
- function(response) {
- //console.log(response);
- });
+ if(tabs[i].url.indexOf('chrome://')===0)continue;
+
+ chrome.tabs.sendMessage(
+ tabs[i].id,
+ data
+ /** 这个回调会导致连接失败时 runtime.lastError 会报错;
+ * 目前导致连接失败的原因有:1.以chrome://开头的tab 是连不上的;2.在插件刷新之前就打开的tab页
+ ,
+ function(response) {
+ //console.log(response);
+ return true;
+ } */
+ );
+
}
})
@@ -275,4 +285,6 @@ chrome.runtime.onInstalled.addListener(details => {
}
+ chrome.runtime.openOptionsPage();
+
});
\ No newline at end of file
diff --git a/content/content.js b/content/content.js
index 41ec6aa..b7aa170 100644
--- a/content/content.js
+++ b/content/content.js
@@ -77,9 +77,9 @@ function MessageListener(){
this.cbs = {};
var _this = this;
chrome.runtime.onMessage.addListener(function(request, sender, sendResponse){
- //sendResponse('ok');
- //console.log(request);
- _this.cbs[request.dataType](request.data);
+ sendResponse('ok');
+ if(typeof _this.cbs[request.dataType] == 'function')
+ _this.cbs[request.dataType](request.data);
});
}
diff --git a/content/search_bar.js b/content/search_bar.js
index 3003509..13817f4 100644
--- a/content/search_bar.js
+++ b/content/search_bar.js
@@ -177,7 +177,7 @@ function jBar() {
let index = 0;
if(num){
index = runtime.historyIndex + num;
- if(index < 0) index = runtime.history.length-1;
+ if(index < 0) index = 0;//runtime.history.length-1;
if(index >= runtime.history.length) index = 0;
}
runtime.historyIndex = index;
diff --git a/manifest.json b/manifest.json
index 49fba08..b8bc113 100644
--- a/manifest.json
+++ b/manifest.json
@@ -4,8 +4,8 @@
"name": "jSearch",
"short_name": "聚搜",
"description": "jSearch(聚搜)是一款专注内容的搜索扩展,一次搜索聚合多平台内容;",
- "version": "1.2.1",
- "update_url": "http://www.jsearch.site",
+ "version": "1.2.2",
+ "update_url": "http://upext.chrome.360.cn/intf.php?method=ExtUpdate.query",
"icons": {
"16": "public/icons/icon128.png",
"48": "public/icons/icon128.png",
diff --git a/options/options.js b/options/options.js
index 4ef1a49..3b3d795 100644
--- a/options/options.js
+++ b/options/options.js
@@ -432,7 +432,7 @@ var app = new Vue({
this.history(this.searchData.keyword);
if(document.getElementById('cz'))
- document.getElementById('cz').src=`http://www.jsearch.site/home/?id=${chrome.runtime.id}&kw=${this.searchData.keyword}`;
+ document.getElementById('cz').src=`http://www.jsearch.site/home/?id=${chrome.runtime.id}`;
},
setKeyword() {
let hash = '';
@@ -666,6 +666,13 @@ var _czc = _czc || [];
//绑定siteid,请用您的siteid替换下方"XXXXXXXX"部分
_czc.push(["_setAccount", "1276484996"]);
+
+
+/**test */
+
+
+
+
var aaa = {
'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8',
'Access-Control-Allow-Credentials': 'true',