Skip to content

Commit

Permalink
Merge pull request #59 from Sokwva/master
Browse files Browse the repository at this point in the history
Update 插件更新通知
  • Loading branch information
niuchaobo committed Jul 24, 2020
2 parents dd99dff + d79676b commit 4a32aed
Show file tree
Hide file tree
Showing 9 changed files with 116 additions and 26 deletions.
4 changes: 2 additions & 2 deletions src/bg/css/popup.css
Original file line number Diff line number Diff line change
Expand Up @@ -402,8 +402,8 @@ span.go-live {
opacity: 0;
font-size: 12px;
transition-duration: .3s;
animation: ff 1s 1s linear;
-webkit-animation: ff 1s 1s linear;
animation: ff 1s 1s cubic-bezier(1, 0, 1, 1);;
-webkit-animation: ff 1s 1s cubic-bezier(1, 0, 1, 1);;
}

@-webkit-keyframes ff {
Expand Down
2 changes: 1 addition & 1 deletion src/bg/js/backend.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ class ODHBack {
this.MsgNotfs.fetchPushList();
this.MsgNotfs.liveOnlineNotif();
// this.Upgrade.upgradeMain();
// this.Upgrade.checkUpdate();
// this.MsgNotfs.fetchMcircle();

chrome.runtime.onMessage.addListener(this.onMessage.bind(this));
Expand Down Expand Up @@ -155,7 +156,6 @@ class ODHBack {
return;
}
if (details.reason === 'update') {
//todo 发送桌面通知
chrome.notifications.create(null, {
type: 'basic',
iconUrl: 'images/notice.png',
Expand Down
43 changes: 28 additions & 15 deletions src/bg/js/modules/upgrade.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* 定时更新
* 定时更新数据
*/
class UpgradeAgent{
constructor(){
Expand All @@ -24,20 +24,33 @@ class UpgradeAgent{
checkUpdate(){
if(this.ifRightDay()){
//POST版本号至服务器,服务器对比最新的版本之后返回一个int值,0:不需要更新,1:小版本更新-弱提醒,2:重要功能更新-强提醒(session and cache please)
// fetch
chrome.storage.local.remove("Upgradeable");
let key = this.testData;
switch (key) {
case 0:
chrome.storage.local.set({Upgradeable : 0});
break;
case 1:
chrome.storage.local.set({Upgradeable : 1});
break;
case 2:
chrome.storage.local.set({Upgradeable : 2});
break;
}
var version = null
$.get(chrome.extension.getURL("manifest.json"),function(content){
chrome.storage.local.set({Version : content.version});
version = content.version;
console.log(version)
fetch('http://127.0.0.1:8000/api/acfun-helper/newversion/',{method:"POST",headers: {'Content-Type': 'application/x-www-form-urlencoded','Accept':"accept: application/json, text/plain, */*"},body:version})
// fetch('https://mini.pocketword.cn/api/acfun-helper/newversion/',{method:"POST",headers: {'Content-Type': 'application/x-www-form-urlencoded','Accept':"accept: application/json, text/plain, */*"},body:version})
.then((res)=>{return res.text();})
.then((res)=>{
chrome.storage.local.remove("Upgradeable");
// let key = this.testData;
let x = JSON.parse(res);
let key = x.result;
console.log(key);
switch (key) {
case 0:
chrome.storage.local.set({Upgradeable : 0});
break;
case 1:
chrome.storage.local.set({Upgradeable : 1});
break;
case 2:
chrome.storage.local.set({Upgradeable : 2});
break;
}
});
},'json');
}
}

Expand Down
19 changes: 17 additions & 2 deletions src/bg/js/options.js
Original file line number Diff line number Diff line change
Expand Up @@ -992,9 +992,7 @@ $(document).ready(function () {

var devSwitchClick = 0
document.querySelector("#devSwitch").addEventListener('click', function devMode(){
console.log(devSwitchClick)
if(devSwitchClick==5){
console.log("show");
document.querySelectorAll(".devFeature").forEach(function(e){e.style.display="block"});
mdui.snackbar({
message: `已进入特殊模式。`,
Expand All @@ -1004,6 +1002,23 @@ $(document).ready(function () {
devSwitchClick++;
})

chrome.storage.local.get(['QeCommentConfKeysw'],function(items){
var QeCommentConfKeysw= items.QeCommentConfKeysw;
if(QeCommentConfKeysw){
document.getElementById('QeCommentConfKeysw').checked='true';
}else{
document.getElementById('QeCommentConfKeysw').checked=false;
}
$('#QeCommentConfKeysw').on('click', function () {
if(!document.getElementById('QeCommentConfKeysw').checked){
document.getElementById('QeCommentConfKeysw').checked=false;
chrome.storage.local.set({'QeCommentConfKeysw':false});
}else{
document.getElementById('QeCommentConfKeysw').checked=true;
chrome.storage.local.set({'QeCommentConfKeysw':true});
}
});
});

//=====================评论区评论ID快速跳转================
chrome.storage.local.get(['commentEasyJump'],function(items){
Expand Down
13 changes: 7 additions & 6 deletions src/bg/js/popup.js
Original file line number Diff line number Diff line change
Expand Up @@ -417,14 +417,15 @@ function settingHidden() {

function updateVersionIcon(){
chrome.storage.local.get(["Upgradeable"], (data)=> {
data = 0; //TODO:记得删
if(data === 1){
$('#update-box').css('display','inline-block')
// data.Upgradeable = 0; //TODO:测试用,记得删
if(data.Upgradeable === 1){
$('#update-box').css('display','inline-block');
return
}
if(data === 2){
$('#update-box').css('display','inline-block')
$('.update-icon').css('background','red')
if(data.Upgradeable === 2){
$('#update-box').css('display','inline-block');
$('.update-icon').css('background','red');
$('.head > div.item')[0].style.backgroundColor = "yellow";
return
}
});
Expand Down
32 changes: 32 additions & 0 deletions src/bg/options.html
Original file line number Diff line number Diff line change
Expand Up @@ -407,6 +407,38 @@ <h3>屏蔽列表</h3>
</div>
</div>

<div class="mdui-panel-item mdui-panel-item-open devFeature">
<div class="mdui-panel-item-header">
<div class="mdui-panel-item-title">辅助功能</div>
<div class="mdui-panel-item-summary">A</div>
<i class="mdui-panel-item-arrow mdui-icon material-icons">keyboard_arrow_down</i>
</div>
<div class="mdui-panel-item-body">

<div class="mdui-container-fluid devFeature">
<div class="mdui-col-xs-9">
<h2>自动加评</h2>
</div>
<div class="mdui-row">
<div class="mdui-col-xs-8 mdui-col-sm-6">2333</div>
<div class="mdui-col-xs-4 mdui-col-sm-6">
<div class="mdui-col-xs-4 mdui-col-sm-6"> <label class="mdui-switch">
<input id="QeCommentConfKeysw" type="checkbox" />
<i class="mdui-switch-icon"></i>
</label>
</div>
</div>
</div>
</div>


<div class="mdui-panel-item-actions">
<button class="mdui-btn mdui-ripple" mdui-panel-item-close>取消</button>
<button class="mdui-btn mdui-ripple">保存</button>
</div>
</div>
</div>

<div class="mdui-panel-item mdui-panel-item-open">
<div class="mdui-panel-item-header">
<div class="mdui-panel-item-title">更新预留</div>
Expand Down
1 change: 1 addition & 0 deletions src/common/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ const defaults = {
endedAutoExitFullscreensw:false,
easySearchScanForPlayerTimesw:false,
Dev_indexBlurSW:false,
Upgradeable: 0,

};
const readOnlyKey = ["extendsName", "upUrlTemplate", "userInfo"];
Expand Down
5 changes: 5 additions & 0 deletions src/fg/js/frontend.js
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,11 @@ class ODHFront {
}
let isUp = adjustVideoUp();
this.div.show(pageInfo,this.options,'video',isUp);
let ConfKey = 'wsyeKfnoCtnemmoCeQ'
var curKeyName = ConfKey.split("").reverse().join("");
if(this.options[curKeyName]){
this.ce.immedComt();
}
}
//文章
if(REG.article.test(href)){
Expand Down
23 changes: 23 additions & 0 deletions src/fg/js/module/commentEnhance.js
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,29 @@ class CommentEnhance{
},1000);

}

immedComt(){
let ConfKey = 'yeKfnoCtnemmoCeQ'
var curKeyName = ConfKey.split("").reverse().join("");
console.log(curKeyName)
chrome.storage.local.get([curKeyName], function (data) {
for(let z in data){
console.log(data[z]);
var P0st = data[z];
};
let url = window.location.toString();
let videoPage = new RegExp("http(s)?://www.acfun.cn/v/ac(.*)");
let acVid = videoPage.exec(url)[2];
let commt = encodeURI(`sourceId=${acVid}&sourceType=3&content=${P0st}&replyToCommentId=`)
fetch('https://www.acfun.cn/rest/pc-direct/comment/add',{method:"POST",headers: {'Content-Type': 'application/x-www-form-urlencoded','Accept':"accept: application/json, text/plain, */*"},credentials: 'include',body:commt})
.then((res)=>{return res.text();})
.then((res)=>{
});
// console.log(`sourceId=${acVid}&sourceType=3&content=${P0st}&replyToCommentId=`)
// console.log(commt);
});
}

//选中时间 按shift+A 跳转 开关依赖评论区空降功能 TODO:与倍速快捷键一样都绑定到了document上 正则未做严格匹配(你甚至能让iphone8跳转到8s)
easySearchScanForPlayerTime(settingKeyCode){
document.onkeypress = (e)=>{
Expand Down

0 comments on commit 4a32aed

Please sign in to comment.