Greasy Fork is available in English.

Microsoft Bing Rewards每日任务脚本

自动完成微软Rewards每日搜索任务,每次运行时获取抖音/微博/哔哩哔哩/百度/头条热门词,避免使用同样的搜索词被封号。

< Feedback on Microsoft Bing Rewards每日任务脚本

Review: Good - script works

§
Posted: 19-09-2024

老哥脚本很好用,能不能再加一个定时多少分钟以后运行,想睡觉之前设置好让它自己跑

§
Posted: 24-11-2024

const defaultReminders = [
{ event: '早上自动运行', time: '09:00', type: 'daily' },
{ event: '早上自动运行', time: '10:30', type: 'daily' },

];

function loadReminders() {
const savedReminders = GM_getValue('reminders');
return savedReminders || defaultReminders;
console.log("提醒:"& savedReminders);
}

function saveReminders(reminders) {
GM_setValue('reminders', reminders);
}

function loadButtonPosition() {
const position = GM_getValue('buttonPosition');
return position || { top: '10px', left: '10px' };
}

function saveButtonPosition(position) {
GM_setValue('buttonPosition', position);
}

function loadButtonVisibility() {
return GM_getValue('buttonVisibility', true);
}

function saveButtonVisibility(visibility) {
GM_setValue('buttonVisibility', visibility);
}

const settingsHTML = `

定时提醒设置

×

添加提醒

倒计时功能



开始倒计时

设置
`;

document.body.insertAdjacentHTML('beforeend', settingsHTML);

const buttonPosition = loadButtonPosition();
const openSettingsButton = document.getElementById('open-settings');
openSettingsButton.style.top = buttonPosition.top;
openSettingsButton.style.left = buttonPosition.left;

const buttonVisibility = loadButtonVisibility();
openSettingsButton.style.display = buttonVisibility ? 'block' : 'none';

GM_addStyle(`
#reminder-settings input, #reminder-settings select, #reminder-settings button {
margin: 5px 0;
}
#reminder-list div {
display: flex;
align-items: center;
margin-bottom: 5px;
}
#reminder-list div .event, #reminder-list div .time {
margin-right: 10px;
flex-grow: 1;
}
#reminder-list div .type {
flex-grow: 2;
margin-right: 10px;
}
#reminder-list div button {
flex-grow: 0;
}
`);

function loadReminderList() {
const reminders = loadReminders();
const reminderList = document.getElementById('reminder-list');
reminderList.innerHTML = '';
reminders.forEach((reminder, index) => {
const reminderDiv = document.createElement('div');
reminderDiv.innerHTML = `


提醒一次每天提醒

删除
`;
reminderList.appendChild(reminderDiv);
});
}

function autoSaveReminder() {
const reminders = [];
document.querySelectorAll('#reminder-list div').forEach(div => {
const event = div.querySelector('.event').value;
const time = div.querySelector('.time').value;
const type = div.querySelector('.type').value;
if (event.trim() !== '') {
reminders.push({ event, time, type });
}
});
saveReminders(reminders);
}

function showSettings() {
document.getElementById('reminder-settings').style.display = 'block';
loadReminderList();
}

function hideSettings() {
document.getElementById('reminder-settings').style.display = 'none';
}

document.getElementById('open-settings').addEventListener('click', (e) => {
e.stopPropagation();
const settingsDiv = document.getElementById('reminder-settings');
if (settingsDiv.style.display === 'none') {
showSettings();
} else {
hideSettings();
}
});

document.getElementById('close-settings').addEventListener('click', hideSettings);

window.addEventListener('click', (event) => {
const settingsDiv = document.getElementById('reminder-settings');
if (settingsDiv.style.display !== 'none' && !settingsDiv.contains(event.target) && event.target !== openSettingsButton) {
hideSettings();
}
});

GM_registerMenuCommand('显示/隐藏提醒设置按钮', () => {
const currentVisibility = openSettingsButton.style.display === 'block';
openSettingsButton.style.display = currentVisibility ? 'none' : 'block';
saveButtonVisibility(!currentVisibility);
});

function makeElementDraggable(el) {
let pos1 = 0, pos2 = 0, pos3 = 0, pos4 = 0;
el.onmousedown = dragMouseDown;

function dragMouseDown(e) {
e = e || window.event;
e.preventDefault();
pos3 = e.clientX;
pos4 = e.clientY;
document.onmouseup = closeDragElement;
document.onmousemove = elementDrag;
}

function elementDrag(e) {
e = e || window.event;
e.preventDefault();
pos1 = pos3 - e.clientX;
pos2 = pos4 - e.clientY;
pos3 = e.clientX;
pos4 = e.clientY;
el.style.top = (el.offsetTop - pos2) + "px";
el.style.left = (el.offsetLeft - pos1) + "px";

saveButtonPosition({ top: el.style.top, left: el.style.left });
}

function closeDragElement() {
document.onmouseup = null;
document.onmousemove = null;
}
}

makeElementDraggable(openSettingsButton);

document.getElementById('add-reminder').addEventListener('click', () => {
const reminders = loadReminders();
const now = new Date();
const currentTime = now.toTimeString().substr(0, 5);
reminders.push({ event: '', time: currentTime, type: 'daily' });
saveReminders(reminders);
loadReminderList();
});

document.getElementById('reminder-list').addEventListener('input', autoSaveReminder);

document.getElementById('reminder-list').addEventListener('click', (e) => {
if (e.target.classList.contains('delete-reminder')) {
e.stopPropagation();
const index = e.target.getAttribute('data-index');
const reminders = loadReminders();
reminders.splice(index, 1);
saveReminders(reminders);
loadReminderList();
}
});

const notifiedTimes = new Set();

function checkAndNotify() {
const now = new Date();
const currentTime = now.toTimeString().substr(0, 5);
let reminders = loadReminders();

reminders.forEach(reminder => {
if (currentTime === reminder.time && !notifiedTimes.has(reminder.time + reminder.event)) {
if (reminder.event.trim() !== '') {
GM_notification({
title: '定时提醒',
text: `该${reminder.event}了!`,
timeout: 10000,
onclick: () => {
console.log(`你点击了${reminder.event}提醒`);
}
});
GM_setValue('Cnt', 0); // 将计数器重置为0
notifiedTimes.add(reminder.time + reminder.event);
}
}
});

// Remove entries from notifiedTimes set to avoid memory issues
notifiedTimes.forEach(key => {
if (!reminders.some(reminder => reminder.time + reminder.event === key && reminder.time === currentTime)) {
notifiedTimes.delete(key);
}
});
}

setInterval(() => {
notifiedTimes.clear();
}, 60000);

document.getElementById('start-countdown').addEventListener('click', () => {
const minutes = parseInt(document.getElementById('countdown-minutes').value, 10);
if (!isNaN(minutes) && minutes > 0) {
GM_notification({
title: '倒计时提醒',
text: `倒计时${minutes}分钟开始!`,
timeout: 5000
});
hideSettings();
setTimeout(() => {
GM_notification({
title: '倒计时提醒',
text: `倒计时${minutes}分钟结束!`,
timeout: 10000
});
}, minutes * 60000);
} else {
alert('请输入有效的分钟数');
}
});

setInterval(checkAndNotify, 1000);
checkAndNotify();

--------------------------

}之前插入这个代码

§
Posted: 24-11-2024

随便 复制个 定时提醒的代码,然后在提醒函数里加了句 GM_setValue('Cnt', 0); // 将计数器重置为0,这样就等于手动按了 开始~~~

Post reply

Sign in to post a reply.