From 8e7a4c7201b195c648a39afaee626682d3ca3d5a Mon Sep 17 00:00:00 2001 From: zimocode Date: Wed, 2 Oct 2019 23:48:29 +0800 Subject: [PATCH 1/5] upgrade tbkjx --- css/inject/tbkjx.css | 53 ++++++++++++-- js/background.js | 45 ++++++++++-- js/inject/tbkjx.js | 161 +++++++++++++++++++++++++++++++++++++++---- manifest.json | 2 +- 4 files changed, 235 insertions(+), 26 deletions(-) diff --git a/css/inject/tbkjx.css b/css/inject/tbkjx.css index 621d645..ce3c655 100644 --- a/css/inject/tbkjx.css +++ b/css/inject/tbkjx.css @@ -43,6 +43,7 @@ smartup.su_apps#su_apps_tbkjx .su_tbkjx_boxsearch input{ padding: 0px 4px; width: 120px; margin: 3px 4px; +margin-left: 0; } smartup.su_apps#su_apps_tbkjx .su_tbkjx_boxsearch button{ min-width: 10px; @@ -52,6 +53,7 @@ smartup.su_apps#su_apps_tbkjx .su_tbkjx_boxsearch button{ display: inline-block; float: right; margin: 4px auto; + padding: 0; /**/ float: initial; margin-left: 4px; @@ -60,8 +62,44 @@ smartup.su_apps#su_apps_tbkjx .su_tbkjx_headspan{ font-size: 10px; color: #333; } - - +smartup.su_apps#su_apps_tbkjx .su_tbkjx_sort{ + margin-top: 2px; +} +smartup.su_apps#su_apps_tbkjx .su_tbkjx_sortbtn{ + font-size: 10px; + height: 18px; + line-height: 18px; + min-width: auto; + padding: 0 4px; + margin: 0; +} +smartup.su_apps#su_apps_tbkjx .su_tbkjx_sortbtncur{ + color: rgb(255, 255, 255); + background: rgb(86, 119, 252); +} +smartup.su_apps#su_apps_tbkjx .su_tbkjx_extent{ + padding: 4px 0; +} +smartup.su_apps#su_apps_tbkjx .su_tbkjx_extenttext{ + width: 35px; + padding: 0 2px; + margin: 0 2px; + height: 18px; + font-size: 10px; +} +smartup.su_apps#su_apps_tbkjx .su_tbkjx_extentbtn{ + width: 40px; + min-width: auto; + font-size: 12px; + height: 18px; + line-height: 18px; + padding: 0; + margin: 0; + margin-left: 4px; +} +smartup.su_apps#su_apps_tbkjx .su_tbkjx_extentspan{ + font-size: 10px; +} smartup.su_apps#su_apps_tbkjx .su_tbkjx_img{ height: 360px; width: 360px; @@ -79,6 +117,7 @@ smartup.su_apps#su_apps_tbkjx .su_tbkjx_name{ smartup.su_apps#su_apps_tbkjx .su_tbkjx_btnbox{ width: 360px; margin: 0; + padding: 0; background-color: red; color: #fff; } @@ -101,10 +140,10 @@ smartup.su_apps#su_apps_tbkjx .su_tbkjx_buy{ padding-left: 8px; } smartup.su_apps#su_apps_tbkjx .su_tbkjx_listjing{ - padding-top: 72px; + padding-top: 86px; padding-top: 0; -margin-top: 72px; +margin-top: 86px; position: initial; } smartup.su_apps#su_apps_tbkjx .su_tbkjx_listjing ul{ @@ -116,7 +155,7 @@ height: 288px; overflow-y: auto; overflow-x: hidden; height: 328px; -height: 320px; +height: 298px; padding: 2px 0; } smartup.su_apps#su_apps_tbkjx .su_tbkjx_listjing li{ @@ -183,4 +222,8 @@ smartup.su_apps#su_apps_tbkjx .su_tbkjx_listbottom button:disabled:hover{ color: #000; cursor: not-allowed; box-shadow: none; +} +smartup.su_apps#su_apps_tbkjx .su_tbkjx_des{ + font-size: 10px; + color: #333; } \ No newline at end of file diff --git a/js/background.js b/js/background.js index 2624cf2..172b307 100644 --- a/js/background.js +++ b/js/background.js @@ -1141,6 +1141,16 @@ var sub={ } return theIndex; }, + date:{ + date:new Date(), + get:function(){ + var _newDate=this.date.getFullYear().toString()+((this.date.getMonth()+1)<10?("0"+(this.date.getMonth()+1)):(this.date.getMonth()+1).toString())+(this.date.getDate()<10?("0"+this.date.getDate()):this.date.getDate().toString()); + return Number(_newDate); + }, + getTime:function(){ + return this.date.getTime(); + } + }, showNotif:function(type,title,txt){ var notif={ iconUrl:"icon.png", @@ -4243,16 +4253,37 @@ var sub={ }, tbkjx:{ getData:function(message,sender,sendResponse){ - console.log("tbkjx.getdata"); - let _url="tbkjx.json"; - // let _url="https://quan.zimoapps.com/push/tbkjx.json"; - let _date=new Date(); - _url=_url+"?"+_date.getFullYear()+((_date.getMonth()+1)<10?("0"+(_date.getMonth()+1)):(_date.getMonth()+1))+(_date.getDate()<10?("0"+_date.getDate()):_date.getDate()) - fetch(_url) + // ======================= + // let _url="tbkjx.json", + // _configURL="https://quan.zimoapps.com/push/config.json"+"?"+sub.date.getTime(); + // ======================= + let _url="https://quan.zimoapps.com/push/tbkjx.json", + _configURL="https://quan.zimoapps.com/push/config.json"+"?"+sub.date.getTime(); + fetch(_configURL) .then(response=>response.json()) .then(json=>{ - chrome.tabs.sendMessage(sender.tab.id,{type:"data",value:json}); + if(!localStorage.getItem("tbkjx_dataversion")||Number(json.version)>sub.date.get()){ + _url=_url+"?"+sub.date.get().toString(); + localStorage.setItem("tbkjx_dataversion",json.version); + }else{ + _url=_url+"?"+localStorage.getItem("tbkjx_dataversion"); + } + console.log(_url); + fetch(_url) + .then(response=>response.json()) + .then(json=>{ + chrome.tabs.sendMessage(sender.tab.id,{type:"data",value:json}); + }) }) + // ======================= + + // let _date=new Date(); + // _url=_url+"?"+_date.getFullYear()+((_date.getMonth()+1)<10?("0"+(_date.getMonth()+1)):(_date.getMonth()+1))+(_date.getDate()<10?("0"+_date.getDate()):_date.getDate()) + // fetch(_url) + // .then(response=>response.json()) + // .then(json=>{ + // chrome.tabs.sendMessage(sender.tab.id,{type:"data",value:json}); + // }) }, itemOpen:function(message,sender,sendResponse){ sub.open(message.value); diff --git a/js/inject/tbkjx.js b/js/inject/tbkjx.js index 351e068..4c43e19 100644 --- a/js/inject/tbkjx.js +++ b/js/inject/tbkjx.js @@ -34,17 +34,42 @@ sue.apps.tbkjx={ boxSearch.appendChild(sue.apps.domCreate("input",{setName:["id","placeholder","type"],setValue:["su_tbkjx_searchkey","键入关键字搜索","text"]},null,null,null)); boxSearch.appendChild(sue.apps.domCreate("button",{setName:["id"],setValue:["su_tbkjx_search"]},null,null,null,"搜索")); - let headSpan=sue.apps.domCreate("span",{setName:["className"],setValue:["su_tbkjx_headspan"]},null,null,null,"1.部分商品由于商家调价,价格有一定变化\n2.只买对的,不买便宜的(*^_^*)") + let headSpan=sue.apps.domCreate("span",{setName:["className"],setValue:["su_tbkjx_headspan"]},null,null,null,"1.部分商品由于商家调价,价格有一定变化\n2.只买对的,不买便宜的(*^_^*)"); + + let headSort=sue.apps.domCreate("div",{setName:["className"],setValue:["su_tbkjx_sort"]}); + let _sortReset=sue.apps.domCreate("button",{setName:["className"],setValue:["su_tbkjx_sortbtn su_tbkjx_sortreset"]},null,null,null,"默认排序"), + _sortUp=sue.apps.domCreate("button",{setName:["className"],setValue:["su_tbkjx_sortbtn su_tbkjx_sortup"]},null,"margin:0 5px;",null,"价格由低到高"), + _sortDn=sue.apps.domCreate("button",{setName:["className"],setValue:["su_tbkjx_sortbtn su_tbkjx_sortdn"]},null,null,null,"价格由高到低"); + headSort.appendChild(_sortReset); + headSort.appendChild(_sortUp); + headSort.appendChild(_sortDn); + + let headExtent=sue.apps.domCreate("div",{setName:["className"],setValue:["su_tbkjx_extent"]}); + let _extentSpan=sue.apps.domCreate("span",{setName:["className"],setValue:["su_tbkjx_extentspan"]},null,null,null,"价格范围:"), + _extentFrom=sue.apps.domCreate("input",{setName:["className","id","placeholder","type"],setValue:["su_tbkjx_extenttext","su_tbkjx_extentfrom","最低价","text"]},null,null,null), + _extentDash=sue.apps.domCreate("span",{setName:["className"],setValue:["su_tbkjx_extenttext"]},null,"font-size:10px;",null,"~"), + _extentTo=sue.apps.domCreate("input",{setName:["className","id","placeholder","type"],setValue:["su_tbkjx_extenttext","su_tbkjx_extento","最高价","text"]},null,null,null), + _extentBtn=sue.apps.domCreate("button",{setName:["className","id"],setValue:["su_tbkjx_extentbtn","su_tbkjx_extentbtn"]},null,null,null,"确定"); + headExtent.appendChild(_extentSpan); + headExtent.appendChild(_extentFrom); + headExtent.appendChild(_extentDash); + headExtent.appendChild(_extentTo); + headExtent.appendChild(_extentBtn); + let _bottomPre=sue.apps.domCreate("button",{setName:["id","className","title"],setValue:["su_tbkjx_btnpre","su_tbkjx_page","上一页"]},null,null,null,"<"), _bottomHome=sue.apps.domCreate("button",{setName:["id","className","title"],setValue:["su_tbkjx_btnhome","su_tbkjx_page","第一页"]},null,"width:40px;margin:0 4px;",{setName:["page"],setValue:["0"]},"□"), - _bottomNext=sue.apps.domCreate("button",{setName:["id","className","title"],setValue:["su_tbkjx_btnnext","su_tbkjx_page","下一页"]},null,null,null,">"); + _bottomNext=sue.apps.domCreate("button",{setName:["id","className","title"],setValue:["su_tbkjx_btnnext","su_tbkjx_page","下一页"]},null,null,null,">"), + _bottomDes=sue.apps.domCreate("div",{setName:["className"],setValue:["su_tbkjx_des"]},null,null,null,"只买需要的,不买便宜的(*^_^*)"); listBottom.appendChild(_bottomPre); listBottom.appendChild(_bottomHome); listBottom.appendChild(_bottomNext); + listBottom.appendChild(_bottomDes); listHead.appendChild(boxSearch); - listHead.appendChild(headSpan); + // listHead.appendChild(headSpan); + listHead.appendChild(headSort); + listHead.appendChild(headExtent); boxList.appendChild(listHead); boxList.appendChild(listJing); @@ -81,7 +106,8 @@ sue.apps.tbkjx={ _dom.appendChild(_btnBox); }, initList:function(data,page){ - sue.apps.tbkjx.cons.curData=data; + // sue.apps.tbkjx.cons.curData=data; + sue.apps.tbkjx.cons.curData=data.slice(0); //// let _listLength=sue.apps.tbkjx.config.n_num; let _page=page; @@ -111,6 +137,7 @@ sue.apps.tbkjx={ sue.apps.tbkjx.itemSwitch(_dom.querySelector("li")); sue.apps.tbkjx.itemInit(data[0]); + sue.apps.tbkjx.setSortBtn(); }, handleEvent:function(e){ switch(e.type){ @@ -133,25 +160,72 @@ sue.apps.tbkjx={ if(e.target.classList.contains("su_tbkjx_page")){ sue.apps.tbkjx.initList(sue.apps.tbkjx.cons.curData,e.target.dataset.page); } + if(e.target.classList.contains("su_tbkjx_sortbtn")){ + let sortType="up"; + if(e.target.classList.contains("su_tbkjx_sortup")){ + sortType="up"; + }else if(e.target.classList.contains("su_tbkjx_sortdn")){ + sortType="dn"; + }else{ + sortType="reset"; + } + sue.apps.tbkjx.itemSort(sortType); + } + if(e.target.classList.contains("su_tbkjx_extentbtn")){ + sue.apps.tbkjx.itemExtent(); + } break case"keypress": - if(e.keyCode==13){ - sue.apps.tbkjx.itemSearch(); + if(e.keyCode==13&&e.target.id=="su_tbkjx_searchkey"){ + sue.apps.tbkjx.itemSearch(e.target); + }else if(e.keyCode==13&&e.target.classList.contains("su_tbkjx_extenttext")){ + sue.apps.tbkjx.itemExtent(); } break } }, itemSearch:function(){ - console.log("itemSearch") - let _key=sue.apps.tbkjx.dom.querySelector("#su_tbkjx_searchkey").value; - console.log(_key); - let newData=[], - data=sue.apps.tbkjx.cons.data; + let _dom=sue.apps.tbkjx.dom; + _dom.querySelector("#su_tbkjx_extentfrom").value=""; + _dom.querySelector("#su_tbkjx_extento").value=""; + + let data=sue.apps.tbkjx.cons.data; + let _keys=_dom.querySelector("#su_tbkjx_searchkey").value.split(" "); + let _newD=[]; + let arrayDiff=function(arr) { + let result = []; + let obj = {}; + for(var i=0;i-1){ + if(!_newD[_num]){_newD[_num]=[]} + _newD[_num].push(data[i]); } } + let concatArray=_newD[_newD.length-1]; + for(var i=_newD.length-1;i>0;i--){ + concatArray=concatArray.concat(_newD[i-1]); + } + + let newData=arrayDiff(concatArray); + + sue.apps.tbkjx.cons.curSort="reset"; + sue.apps.tbkjx.cons.reset=newData; + sue.apps.tbkjx.cons.extentBase=newData; sue.apps.tbkjx.initList(newData,0); }, itemSwitch:function(ele){ @@ -164,6 +238,65 @@ sue.apps.tbkjx={ }, itemOpen:function(link){ chrome.runtime.sendMessage({type:"appsAction",app:"tbkjx",action:"itemOpen",value:link}); + }, + itemSort:function(sortType){ + let compare=function(type){ + return function(m,n){ + var a = m[2]; + var b = n[2]; + if(type=="up"){ + return a - b; + }else{ + return b - a; + } + } + } + if(sortType!="reset"){ + sue.apps.tbkjx.cons[sortType]=sue.apps.tbkjx.cons.curData.sort(compare(sortType)); + } + sue.apps.tbkjx.initList(sue.apps.tbkjx.cons[sortType],0); + sue.apps.tbkjx.cons.curSort=sortType; + sue.apps.tbkjx.setSortBtn(); + + // sue.apps.tbkjx.initList(sue.apps.tbkjx.cons.curData.sort(compare(sortType)),0); + }, + setSortBtn:function(){ + console.log("setSortBtn"); + if(!sue.apps.tbkjx.cons.curSort){sue.apps.tbkjx.cons.curSort="reset"} + let _btns=sue.apps.tbkjx.dom.querySelectorAll(".su_tbkjx_sortbtn"); + for(var i=0;i<_btns.length;i++){ + if(_btns[i].classList.contains("su_tbkjx_sortbtncur")){ + _btns[i].classList.remove("su_tbkjx_sortbtncur"); + } + if(_btns[i].classList.contains("su_tbkjx_sort"+sue.apps.tbkjx.cons.curSort)){ + _btns[i].classList.add("su_tbkjx_sortbtncur"); + } + } + }, + itemExtent:function(){ + let _dom=sue.apps.tbkjx.dom; + let _from=Number(_dom.querySelector("#su_tbkjx_extentfrom").value), + _to=Number(_dom.querySelector("#su_tbkjx_extento").value); + console.log(_from) + + let newData=[], + data=sue.apps.tbkjx.cons.extentBase; + for(var i=0;i=_from){ + newData.push(data[i]); + } + } + if(Number(data[i][2])>=_from&&Number(data[i][2])<=_to){ + newData.push(data[i]); + } + } + + sue.apps.tbkjx.cons.curSort="reset"; + sue.apps.tbkjx.cons.reset=newData; + sue.apps.tbkjx.cons.curData=newData; + sue.apps.tbkjx.itemSort(sue.apps.tbkjx.cons.curSort) + // sue.apps.tbkjx.initList(newData,0); } } chrome.runtime.sendMessage({type:"apps_getvalue",apptype:"tbkjx"},function(response){ @@ -174,6 +307,8 @@ chrome.runtime.onMessage.addListener(function(message,sender,sendResponse) { switch(message.type){ case"data": sue.apps.tbkjx.cons.data=message.value.data; + sue.apps.tbkjx.cons.reset=sue.apps.tbkjx.cons.data.slice(0); + sue.apps.tbkjx.cons.extentBase=sue.apps.tbkjx.cons.data.slice(0); sue.apps.tbkjx.initList(message.value.data,0); break; } diff --git a/manifest.json b/manifest.json index 34d69c8..3c700f3 100644 --- a/manifest.json +++ b/manifest.json @@ -3,7 +3,7 @@ "minimum_chrome_version": "22", "name": "smartUp Gestures(Beta)", "short_name":"smartUp", - "version": "6.5.1240.1020", + "version": "6.5.1240.1022", "description": "__MSG_ext_des__", "default_locale": "en", "author":"zimo", From e63fa02714ac399b3a2e2a052c6b254ceff2fc68 Mon Sep 17 00:00:00 2001 From: zimocode Date: Mon, 7 Oct 2019 22:28:59 +0800 Subject: [PATCH 2/5] upgrade tbkjx --- _locales/en/messages.json | 3 +++ _locales/zh_CN/messages.json | 3 +++ css/inject/tbkjx.css | 21 +++++++++++++++++++++ js/inject/tbkjx.js | 35 ++++++++++++++++++++++++++++------- manifest.json | 2 +- 5 files changed, 56 insertions(+), 8 deletions(-) diff --git a/_locales/en/messages.json b/_locales/en/messages.json index b77db30..9e5919f 100644 --- a/_locales/en/messages.json +++ b/_locales/en/messages.json @@ -1145,6 +1145,9 @@ "app_tip_opt":{ "message":"Options" }, + "app_tip_info":{ + "message":"Information" + }, "app_rss_menu":{ "message":"Menu" }, diff --git a/_locales/zh_CN/messages.json b/_locales/zh_CN/messages.json index d48ee89..f759081 100644 --- a/_locales/zh_CN/messages.json +++ b/_locales/zh_CN/messages.json @@ -1148,6 +1148,9 @@ "app_tip_opt":{ "message":"设置" }, + "app_tip_info":{ + "message":"信息" + }, "app_rss_menu":{ "message":"菜单" }, diff --git a/css/inject/tbkjx.css b/css/inject/tbkjx.css index ce3c655..fba6d70 100644 --- a/css/inject/tbkjx.css +++ b/css/inject/tbkjx.css @@ -226,4 +226,25 @@ smartup.su_apps#su_apps_tbkjx .su_tbkjx_listbottom button:disabled:hover{ smartup.su_apps#su_apps_tbkjx .su_tbkjx_des{ font-size: 10px; color: #333; +} +smartup.su_apps#su_apps_tbkjx .su_options_help{ + position: absolute; + left: 0; + top: 0; + background-color: #fff; + padding: 8px 16px; + width: -webkit-calc(100% - 16px); + width: -moz-calc(100% - 16px); + width: calc(100% - 16px); + margin: 8px; + margin-top: 32px; + box-sizing: border-box; + opacity: 0; + z-index: -1; + box-shadow: 0px 2px 4px #5677fc; +} +smartup.su_apps#su_apps_tbkjx .su_options_help li{ + font-size: 12px; + display: block; + float: unset; } \ No newline at end of file diff --git a/js/inject/tbkjx.js b/js/inject/tbkjx.js index 4c43e19..26b62ca 100644 --- a/js/inject/tbkjx.js +++ b/js/inject/tbkjx.js @@ -7,7 +7,8 @@ sue.apps.tbkjx={ headTitle:"tbkjx", headCloseBtn:true, menu:[ - {src:"/image/options.png",title:"app_tip_opt",className:"menu_item menu_item_opt"} + {src:"/image/options.png",title:"app_tip_opt",className:"menu_item menu_item_opt"}, + {src:"/image/info.svg",title:"app_tip_info",className:"menu_item menu_item_help"} ], options:[ {type:"range",label:"app_tbkjx_num",name:"n_num",min:10,max:100,step:10}, @@ -34,8 +35,6 @@ sue.apps.tbkjx={ boxSearch.appendChild(sue.apps.domCreate("input",{setName:["id","placeholder","type"],setValue:["su_tbkjx_searchkey","键入关键字搜索","text"]},null,null,null)); boxSearch.appendChild(sue.apps.domCreate("button",{setName:["id"],setValue:["su_tbkjx_search"]},null,null,null,"搜索")); - let headSpan=sue.apps.domCreate("span",{setName:["className"],setValue:["su_tbkjx_headspan"]},null,null,null,"1.部分商品由于商家调价,价格有一定变化\n2.只买对的,不买便宜的(*^_^*)"); - let headSort=sue.apps.domCreate("div",{setName:["className"],setValue:["su_tbkjx_sort"]}); let _sortReset=sue.apps.domCreate("button",{setName:["className"],setValue:["su_tbkjx_sortbtn su_tbkjx_sortreset"]},null,null,null,"默认排序"), _sortUp=sue.apps.domCreate("button",{setName:["className"],setValue:["su_tbkjx_sortbtn su_tbkjx_sortup"]},null,"margin:0 5px;",null,"价格由低到高"), @@ -67,7 +66,6 @@ sue.apps.tbkjx={ listBottom.appendChild(_bottomDes); listHead.appendChild(boxSearch); - // listHead.appendChild(headSpan); listHead.appendChild(headSort); listHead.appendChild(headExtent); @@ -78,8 +76,19 @@ sue.apps.tbkjx={ theAppBox.appendChild(boxContent); theAppBox.appendChild(boxList); - chrome.runtime.sendMessage({type:"appsAction",app:"tbkjx",action:"getData",value:"jingxuan"}) + let _infoBox=sue.apps.domCreate("div",{setName:["className"],setValue:["su_options_help"]}), + _info=sue.apps.domCreate("ul"); + _info.appendChild(sue.apps.domCreate("li",null,null,null,null,"1、每日更新上万款优惠券商品,购物前可以从这里搜索是否有和心意的。")); + _info.appendChild(sue.apps.domCreate("li",null,null,null,null,"2、由于商家调价等因素,部分商品价格可能有变动。")); + _info.appendChild(sue.apps.domCreate("li",null,null,null,null,"3、理性购物,多多比较,购买需要的物品。")); + let _li=sue.apps.domCreate("li",null,null,null,null,"4、此迷你应用也有相应的网页版本:"); + let _a=sue.apps.domCreate("a",{setName:["href","target"],setValue:["https://quan.zimoapps.com","_blank"]},null,null,null,"quan.zimoapps.com"); + _li.appendChild(_a); + _info.appendChild(_li); + _infoBox.appendChild(_info); + dom.appendChild(_infoBox); + chrome.runtime.sendMessage({type:"appsAction",app:"tbkjx",action:"getData",value:"jingxuan"}) dom.style.cssText+="border-color:#2b2b34;"; dom.querySelector(".su_head").style.cssText+="background-color:#2b2b34;"; dom.addEventListener("click",this.handleEvent,false); @@ -174,14 +183,17 @@ sue.apps.tbkjx={ if(e.target.classList.contains("su_tbkjx_extentbtn")){ sue.apps.tbkjx.itemExtent(); } - break + if(e.target.classList.contains("menu_item_help")){ + sue.apps.tbkjx.showHelp(e); + } + break; case"keypress": if(e.keyCode==13&&e.target.id=="su_tbkjx_searchkey"){ sue.apps.tbkjx.itemSearch(e.target); }else if(e.keyCode==13&&e.target.classList.contains("su_tbkjx_extenttext")){ sue.apps.tbkjx.itemExtent(); } - break + break; } }, itemSearch:function(){ @@ -297,6 +309,15 @@ sue.apps.tbkjx={ sue.apps.tbkjx.cons.curData=newData; sue.apps.tbkjx.itemSort(sue.apps.tbkjx.cons.curSort) // sue.apps.tbkjx.initList(newData,0); + }, + showHelp:function(e){ + var domopt=sue.apps.getAPPboxEle(e).querySelector(".su_options_help"); + var _opt=window.getComputedStyle(domopt).opacity==0?true:false; + if(_opt){ + domopt.style.cssText+="opacity:.9;z-index:10;"; + }else{ + domopt.style.cssText+="opacity:0;z-index:-1;"; + } } } chrome.runtime.sendMessage({type:"apps_getvalue",apptype:"tbkjx"},function(response){ diff --git a/manifest.json b/manifest.json index 3c700f3..4e761da 100644 --- a/manifest.json +++ b/manifest.json @@ -3,7 +3,7 @@ "minimum_chrome_version": "22", "name": "smartUp Gestures(Beta)", "short_name":"smartUp", - "version": "6.5.1240.1022", + "version": "6.5.1240.1023", "description": "__MSG_ext_des__", "default_locale": "en", "author":"zimo", From cff79a3c60c71378eb076c8e70db8db59584331f Mon Sep 17 00:00:00 2001 From: zimocode Date: Wed, 9 Oct 2019 21:25:27 +0800 Subject: [PATCH 3/5] fix bug: action closeapps --- change.log | 10 +++++++++- js/background.js | 2 +- manifest.json | 2 +- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/change.log b/change.log index 14280a5..71e8eb4 100644 --- a/change.log +++ b/change.log @@ -1,7 +1,15 @@ { "log": [ { - "ver":"6.5.1240.1020", + "ver":"6.5.1341.1024", + "date":"2019.10.09", + "content":[ + "upgrade tbkjx", + "fix bug: action closeapps" + ] + }, + { + "ver":"6.5.1240.1024", "date":"2019.09.26", "content":[ "new mini-apps: homepage,tbkjx.", diff --git a/js/background.js b/js/background.js index 172b307..2f976c5 100644 --- a/js/background.js +++ b/js/background.js @@ -2051,7 +2051,7 @@ var sub={ chrome.runtime.reload(); }, closeapps:function(){ - let _code='var eles=document.querySelectorAll("smartup.su_apps");for(var i=0;i Date: Sun, 13 Oct 2019 21:55:05 +0800 Subject: [PATCH 4/5] tbkjx: fix bug and upgrade --- css/inject/tbkjx.css | 20 ++++++++++-- js/background.js | 5 +-- js/inject/tbkjx.js | 74 +++++++++++++++++++++++++++++++++++--------- manifest.json | 2 +- 4 files changed, 81 insertions(+), 20 deletions(-) diff --git a/css/inject/tbkjx.css b/css/inject/tbkjx.css index fba6d70..1f5bffe 100644 --- a/css/inject/tbkjx.css +++ b/css/inject/tbkjx.css @@ -78,7 +78,9 @@ smartup.su_apps#su_apps_tbkjx .su_tbkjx_sortbtncur{ background: rgb(86, 119, 252); } smartup.su_apps#su_apps_tbkjx .su_tbkjx_extent{ - padding: 4px 0; + /*padding: 4px 0;*/ + padding: 0; + margin-bottom: 4px; } smartup.su_apps#su_apps_tbkjx .su_tbkjx_extenttext{ width: 35px; @@ -104,6 +106,7 @@ smartup.su_apps#su_apps_tbkjx .su_tbkjx_img{ height: 360px; width: 360px; display: block; + cursor: pointer; } smartup.su_apps#su_apps_tbkjx .su_tbkjx_name{ width: 360px; @@ -143,7 +146,7 @@ smartup.su_apps#su_apps_tbkjx .su_tbkjx_listjing{ padding-top: 86px; padding-top: 0; -margin-top: 86px; +margin-top: 106px; position: initial; } smartup.su_apps#su_apps_tbkjx .su_tbkjx_listjing ul{ @@ -155,7 +158,7 @@ height: 288px; overflow-y: auto; overflow-x: hidden; height: 328px; -height: 298px; +height: 278px; padding: 2px 0; } smartup.su_apps#su_apps_tbkjx .su_tbkjx_listjing li{ @@ -247,4 +250,15 @@ smartup.su_apps#su_apps_tbkjx .su_options_help li{ font-size: 12px; display: block; float: unset; +} +smartup.su_apps#su_apps_tbkjx .su_tbkjx_qr{ + position: absolute; + left: 16px; + bottom: 76px; +} +smartup.su_apps#su_apps_tbkjx .su_tbkjx_qr img{ + width: 0px; + height: 0px; + opacity: 0; + cursor: pointer; } \ No newline at end of file diff --git a/js/background.js b/js/background.js index 2f976c5..c73468f 100644 --- a/js/background.js +++ b/js/background.js @@ -3583,7 +3583,8 @@ var sub={ }else if(message.apptype=="qr"){ chrome.tabs.executeScript({file:"js/qrcode.js",runAt:"document_start"},function(){}) }else if(message.apptype=="tbkjx"){ - chrome.tabs.executeScript({file:"js/purify.js",runAt:"document_start"},function(){}) + chrome.tabs.executeScript({file:"js/purify.js",runAt:"document_start"},function(){}); + chrome.tabs.executeScript({file:"js/qrcode.js",runAt:"document_start"},function(){}); } chrome.tabs.insertCSS({file:"css/inject/"+message.apptype+".css",runAt:"document_start"},function(){}); @@ -4262,7 +4263,7 @@ var sub={ fetch(_configURL) .then(response=>response.json()) .then(json=>{ - if(!localStorage.getItem("tbkjx_dataversion")||Number(json.version)>sub.date.get()){ + if(!localStorage.getItem("tbkjx_dataversion")||Number(json.version)>=sub.date.get()){ _url=_url+"?"+sub.date.get().toString(); localStorage.setItem("tbkjx_dataversion",json.version); }else{ diff --git a/js/inject/tbkjx.js b/js/inject/tbkjx.js index 26b62ca..2fe8d8b 100644 --- a/js/inject/tbkjx.js +++ b/js/inject/tbkjx.js @@ -38,10 +38,14 @@ sue.apps.tbkjx={ let headSort=sue.apps.domCreate("div",{setName:["className"],setValue:["su_tbkjx_sort"]}); let _sortReset=sue.apps.domCreate("button",{setName:["className"],setValue:["su_tbkjx_sortbtn su_tbkjx_sortreset"]},null,null,null,"默认排序"), _sortUp=sue.apps.domCreate("button",{setName:["className"],setValue:["su_tbkjx_sortbtn su_tbkjx_sortup"]},null,"margin:0 5px;",null,"价格由低到高"), - _sortDn=sue.apps.domCreate("button",{setName:["className"],setValue:["su_tbkjx_sortbtn su_tbkjx_sortdn"]},null,null,null,"价格由高到低"); + _sortDn=sue.apps.domCreate("button",{setName:["className"],setValue:["su_tbkjx_sortbtn su_tbkjx_sortdn"]},null,null,null,"价格由高到低"), + _sortCup=sue.apps.domCreate("button",{setName:["className"],setValue:["su_tbkjx_sortbtn su_tbkjx_sortcup"]},null,null,null,"优惠券额由低到高"), + _sortCdn=sue.apps.domCreate("button",{setName:["className"],setValue:["su_tbkjx_sortbtn su_tbkjx_sortcdn"]},null,"margin:4px;",null,"优惠券额由高到低"); headSort.appendChild(_sortReset); headSort.appendChild(_sortUp); headSort.appendChild(_sortDn); + headSort.appendChild(_sortCup); + headSort.appendChild(_sortCdn); let headExtent=sue.apps.domCreate("div",{setName:["className"],setValue:["su_tbkjx_extent"]}); let _extentSpan=sue.apps.domCreate("span",{setName:["className"],setValue:["su_tbkjx_extentspan"]},null,null,null,"价格范围:"), @@ -80,8 +84,9 @@ sue.apps.tbkjx={ _info=sue.apps.domCreate("ul"); _info.appendChild(sue.apps.domCreate("li",null,null,null,null,"1、每日更新上万款优惠券商品,购物前可以从这里搜索是否有和心意的。")); _info.appendChild(sue.apps.domCreate("li",null,null,null,null,"2、由于商家调价等因素,部分商品价格可能有变动。")); - _info.appendChild(sue.apps.domCreate("li",null,null,null,null,"3、理性购物,多多比较,购买需要的物品。")); - let _li=sue.apps.domCreate("li",null,null,null,null,"4、此迷你应用也有相应的网页版本:"); + _info.appendChild(sue.apps.domCreate("li",null,null,null,null,"3、点击商品图片显示领券地址的二维码。可以通过手机淘宝扫码在手机上领券购买!")); + _info.appendChild(sue.apps.domCreate("li",null,null,null,null,"4、理性购物,多多比较,购买需要的物品。")); + let _li=sue.apps.domCreate("li",null,null,null,null,"5、此迷你应用也有相应的网页版本:"); let _a=sue.apps.domCreate("a",{setName:["href","target"],setValue:["https://quan.zimoapps.com","_blank"]},null,null,null,"quan.zimoapps.com"); _li.appendChild(_a); _info.appendChild(_li); @@ -93,16 +98,19 @@ sue.apps.tbkjx={ dom.querySelector(".su_head").style.cssText+="background-color:#2b2b34;"; dom.addEventListener("click",this.handleEvent,false); dom.addEventListener("keypress",this.handleEvent,false); + dom.addEventListener("mouseover",this.handleEvent,false); }, itemInit:function(data){ let _dom=sue.apps.tbkjx.dom.querySelector(".su_main .su_tbkjx_boxcontent"); _dom.textContent=""; - let _img=sue.apps.domCreate("img",{setName:["className","src"],setValue:["su_tbkjx_img",data[1]]}), + // let _img=sue.apps.domCreate("img",{setName:["className","src"],setValue:["su_tbkjx_img",data[1]]}), + let _img=sue.apps.domCreate("div",{setName:["className","title"],setValue:["su_tbkjx_img","点击图片显示领券地址的二维码。\n通过手机淘宝扫码在手机上领券购买!"]},null,"background-image:url("+data[1]+");background-size:contain"), + _name=sue.apps.domCreate("div",{setName:["className","title"],setValue:["su_tbkjx_name",DOMPurify.sanitize(data[0])]},null,null,null,DOMPurify.sanitize(data[0])), _spanPrice=sue.apps.domCreate("span",{setName:["className"],setValue:["su_tbkjx_spanprice su_tbkjx_open"]},null,null,{setName:["link"],setValue:[DOMPurify.sanitize(data[3])]},"券后价"), _price=sue.apps.domCreate("span",{setName:["className"],setValue:["su_tbkjx_price su_tbkjx_open"]},null,null,{setName:["link"],setValue:[DOMPurify.sanitize(data[3])]},"¥"+DOMPurify.sanitize(data[2])), - _buy=sue.apps.domCreate("span",{setName:["className"],setValue:["su_tbkjx_buy su_tbkjx_open"]},null,null,{setName:["link"],setValue:[DOMPurify.sanitize(data[3])]},"前往领券"), + _buy=sue.apps.domCreate("span",{setName:["className"],setValue:["su_tbkjx_buy su_tbkjx_open"]},null,null,{setName:["link"],setValue:[DOMPurify.sanitize(data[3])]},"前往领券(¥"+DOMPurify.sanitize(data[4])+")"), _btnBox=sue.apps.domCreate("button",{setName:["className"],setValue:["su_tbkjx_btnbox su_tbkjx_open"]},null,null,{setName:["link"],setValue:[DOMPurify.sanitize(data[3])]}); @@ -113,6 +121,13 @@ sue.apps.tbkjx={ _dom.appendChild(_img); _dom.appendChild(_name); _dom.appendChild(_btnBox); + + let _domQr=sue.apps.domCreate("div",{setName:["className"],setValue:["su_tbkjx_qr"]},null,"display:none;"); + new QRCode(_domQr,data[3]); + _img.appendChild(_domQr); + window.setTimeout(function(){ + _domQr.style.cssText+="display:block;"; + },500) }, initList:function(data,page){ // sue.apps.tbkjx.cons.curData=data; @@ -175,6 +190,10 @@ sue.apps.tbkjx={ sortType="up"; }else if(e.target.classList.contains("su_tbkjx_sortdn")){ sortType="dn"; + }else if(e.target.classList.contains("su_tbkjx_sortcup")){ + sortType="cup"; + }else if(e.target.classList.contains("su_tbkjx_sortcdn")){ + sortType="cdn"; }else{ sortType="reset"; } @@ -186,6 +205,9 @@ sue.apps.tbkjx={ if(e.target.classList.contains("menu_item_help")){ sue.apps.tbkjx.showHelp(e); } + if(e.target.classList.contains("su_tbkjx_img")||(e.target.parentNode&&e.target.parentNode.classList.contains("su_tbkjx_qr"))){ + sue.apps.tbkjx.showQR(); + } break; case"keypress": if(e.keyCode==13&&e.target.id=="su_tbkjx_searchkey"){ @@ -196,6 +218,17 @@ sue.apps.tbkjx={ break; } }, + showQR:function(){ + var _qrImg=sue.apps.tbkjx.dom.querySelector(".su_tbkjx_qr img"); + console.log(_qrImg) + var _qrState=window.getComputedStyle(_qrImg).width=="0px"?true:false; + console.log(_qrState) + if(_qrState){ + _qrImg.style.cssText+="width:345px;height:345px;opacity:1;"; + }else{ + _qrImg.style.cssText+="width:0px;height:0px;opacity:0;"; + } + }, itemSearch:function(){ let _dom=sue.apps.tbkjx.dom; _dom.querySelector("#su_tbkjx_extentfrom").value=""; @@ -207,6 +240,7 @@ sue.apps.tbkjx={ let arrayDiff=function(arr) { let result = []; let obj = {}; + if(!arr){return result;} for(var i=0;i Date: Wed, 16 Oct 2019 21:41:47 +0800 Subject: [PATCH 5/5] upgrade tbkjx, fix:added new options for miniapps don't work --- change.log | 8 ++++---- js/background.js | 14 ++++++++++++-- js/inject/tbkjx.js | 3 +++ manifest.json | 2 +- 4 files changed, 20 insertions(+), 7 deletions(-) diff --git a/change.log b/change.log index 71e8eb4..36b9ef7 100644 --- a/change.log +++ b/change.log @@ -1,15 +1,15 @@ { "log": [ { - "ver":"6.5.1341.1024", - "date":"2019.10.09", + "ver":"6.5.1348.1026", + "date":"2019.10.16", "content":[ "upgrade tbkjx", - "fix bug: action closeapps" + "fix bug: action closeapps, added new options for miniapps don't work" ] }, { - "ver":"6.5.1240.1024", + "ver":"6.5.1240.1020", "date":"2019.09.26", "content":[ "new mini-apps: homepage,tbkjx.", diff --git a/js/background.js b/js/background.js index c73468f..69ed455 100644 --- a/js/background.js +++ b/js/background.js @@ -856,7 +856,7 @@ var appConfmodel={ synced:{n_closebox:true}, jslist:{n_closebox:true}, homepage:{n_optype:"s_new",n_position:"s_default",n_pin:false,n_closebox:true,n_homepage_icon:true,n_homepage_bg:true,n_homepage_resize:true,type:"topsites",site:[{title:"Google",url:"https://www.google.com"}]}, - tbkjx:{n_num:50} + tbkjx:{n_num:50,n_optype:"s_new",n_position:"s_default",n_pin:false} } var sub={ @@ -1165,6 +1165,12 @@ var sub={ if(!config.apps[appname]){ config.apps[appname]=appConfmodel[appname]; chrome.storage.sync.set(JSON.parse(JSON.stringify(config)),function(){}); + }else{ + for(var i in appConfmodel[appname]){ + if(config.apps[appname][i]===undefined){ + config.apps[appname][i]=appConfmodel[appname][i]; + } + } } }, insertTest:function(appname){ @@ -4287,7 +4293,11 @@ var sub={ // }) }, itemOpen:function(message,sender,sendResponse){ - sub.open(message.value); + let _URL=message.value, + _Target=config.apps[message.app].n_optype, + _Index=sub.getIndex(config.apps[message.app].n_position,"new")[0], + _Pin=config.apps[message.app].n_pin; + sub.open(_URL,_Target,_Index,_Pin); } } } diff --git a/js/inject/tbkjx.js b/js/inject/tbkjx.js index 2fe8d8b..6fd83dc 100644 --- a/js/inject/tbkjx.js +++ b/js/inject/tbkjx.js @@ -12,6 +12,9 @@ sue.apps.tbkjx={ ], options:[ {type:"range",label:"app_tbkjx_num",name:"n_num",min:10,max:100,step:10}, + {type:"select",label:"n_optype",name:"n_optype",value:["s_new","s_back","s_current","s_incog"]}, + {type:"select",label:"n_position",name:"n_position",value:["s_default","s_left","s_right","s_head","s_last"]}, + {type:"checkbox",label:"n_pin",name:"n_pin",checked:true} ] } sue.apps.init(); diff --git a/manifest.json b/manifest.json index b197110..ed6fe6f 100644 --- a/manifest.json +++ b/manifest.json @@ -3,7 +3,7 @@ "minimum_chrome_version": "22", "name": "smartUp Gestures(Beta)", "short_name":"smartUp", - "version": "6.5.1341.1025", + "version": "6.5.1348.1026", "description": "__MSG_ext_des__", "default_locale": "en", "author":"zimo",