// ==UserScript==
// @author Gamyou
// @version 1.5.0
// @note 23-03-11 1.5.0 适配框架2.4.0版本
// @note 23-03-08 1.4.6 隐藏弹幕输入框上层显示的登录提示层
// @note 23-02-10 1.4.5 隐藏播放器左上角的“小橙车”提示
// @note 22-08-28 1.4.4 解決定時器在浏览器繁忙时时间出现偏差的问题
// @note 22-08-26 1.4.3 修复正则替换方法not found的问题
// @note 22-08-14 1.4.2 修复B站直播间因活动而嵌套网页而导致房间号解析出错的BUG
// @note 22-08-14 1.4.1 修复B站直播间因活动而嵌套网页而导致脚本加载出错的BUG
// @note 22-08-13 1.4.0 实现阿B各直播间数据分离保存和油猴脚本更新提示功能
// @note 22-08-05 1.3.0 增加播放器底部登录提示和Haruna的隐藏功能
// @note 22-07-29 1.2.6 修复初始化后的常量被赋值和没能初始化成功组件时系统提示加载超时的问题
// @note 22-07-24 1.2.5 增加分组启用按钮,并优化设置面板样式
// @note 22-07-23 1.2.4 修复弹幕分组数据都为空时,旧数据重复合并的BUG
// @note 22-07-16 1.2.3 修复设置弹幕时旧(初始)数据没有清空的BUG
// @note 22-06-24 1.2.2 优化部分代码
// @note 22-06-20 1.2.1 修复定时停止不能再开始的BUG
// @note 22-06-19 1.2.0 添加弹幕设置功能
// ==/UserScript==
(function () {
window.autoSendDanmuModuleLoaded = false;
const blobURL = URL.createObjectURL(
new Blob(
[
'(',
function () {
const ids = {};
// 监听message 开始执行定时器或者销毁
self.onmessage = (e) => {
switch (e.data.command) {
case 'interval:start': // 开启定时器
const intervalId = setInterval(() => postMessage({ message: 'interval:tick', id: e.data.id }), e.data.interval);
// postMessage({ message: 'interval:started', id: e.data.id });
ids[e.data.id] = intervalId;
break;
case 'interval:clear': // 销毁
clearInterval(ids[e.data.id]);
postMessage({ message: 'interval:cleared', id: e.data.id });
delete ids[e.data.id];
break;
case 'timeout:start':
const timeoutId = setTimeout(() => postMessage({ message: 'timeout:tick', id: e.data.id }), e.data.timeout);
// postMessage({ message: 'timeout:started', id: e.data.id });
ids[e.data.id] = timeoutId;
break;
case 'timeout:clear':
clearTimeout(ids[e.data.id]);
postMessage({ message: 'timeout:cleared', id: e.data.id });
delete ids[e.data.id];
break;
}
};
}.toString(),
')()',
],
{ type: 'application/javascript' },
),
);
const worker = new Worker(blobURL);
URL.revokeObjectURL(blobURL); //用完释放URL对象
const workerTimer = {
id: 0,
callbacks: {},
setInterval: (cb, interval, context) => {
const id = ++workerTimer.id;
workerTimer.callbacks[id] = { fn: cb, context: context };
worker.postMessage({ command: 'interval:start', interval: interval, id: id });
return id;
},
setTimeout: (cb, timeout, context) => {
const id = ++workerTimer.id;
workerTimer.callbacks[id] = { fn: cb, context: context };
worker.postMessage({ command: 'timeout:start', timeout: timeout, id: id });
return id;
},
// 监听worker 里面的定时器发送的message 然后执行回调函数
onMessage: (e) => {
switch (e.data.message) {
case 'interval:tick':
case 'timeout:tick':
const callbackItem = workerTimer.callbacks[e.data.id];
if (callbackItem && callbackItem.fn)
callbackItem.fn.apply(callbackItem.context);
break;
case 'interval:cleared':
case 'timeout:cleared':
delete workerTimer.callbacks[e.data.id];
break;
}
},
// 往worker里面发送销毁指令
clearInterval: (id) => worker.postMessage({ command: 'interval:clear', id: id }),
clearTimeout: (id) => worker.postMessage({ command: 'timeout:clear', id: id }),
};
worker.onmessage = workerTimer.onMessage.bind(workerTimer);
let source = {
version: 3,
random: true,
data1: { available: true, values: ['弹幕①', '弹幕②'] },
data2: { available: true, values: ['弹幕③', '弹幕④'] },
data3: { available: true, values: ['弹幕⑤', '弹幕⑥'] },
data4: { available: true, values: ['弹幕⑦', '弹幕⑧'] },
data5: { available: true, values: ['弹幕⑨', '弹幕Ⅹ'] }
},
pdata = {}, waiters = [], data = [], sendTimer = null, removeElementsTimer = null, signInTimer = null;
count = 0, waitCount = 20, arrayIndex = 0, removeElementsTimerCount = 0, default_timeout = 600,
rdCheckbox, group1Checkbox, group2Checkbox, group3Checkbox, group4Checkbox, group5Checkbox,
dmButtonSend, dmInput, divSetting, dataText1, dataText2, dataText3, dataText4, dataText5, spanApplyTip,
gmNotice = obj => { alert('请更新油猴脚本'); window.location.href = parentUrl; },
getGmValue = (key, defaultValue) => { return null; },
setGmValue = (key, obj) => { console.warn('===> No implementation "setGmValue" method.'); },
delGmValue = key => { console.warn('===> No implementation "delGmValue" method.'); };
// const minVersion = '2.4.0', noticeTimeout = 10000,
// icoUrl = 'https://www.bilibili.com/favicon.ico',
// parentUrl = 'https://greasyfork.org/scripts/446725-b%E7%AB%99%E7%9B%B4%E6%92%AD%E9%97%B4%E5%AE%9A%E6%97%B6%E5%8F%91%E9%9A%8F%E6%9C%BA%E5%BC%B9%E5%B9%95/code/B%E7%AB%99%E7%9B%B4%E6%92%AD%E9%97%B4%E5%AE%9A%E6%97%B6%E5%8F%91%E9%9A%8F%E6%9C%BA%E5%BC%B9%E5%B9%95.user.js',
// roomId = window.__NEPTUNE_IS_MY_WAIFU__
// ? window.__NEPTUNE_IS_MY_WAIFU__.roomInfoRes.data.room_info.room_id
// : window.location.pathname.replace(/^\/(\S+\/)*/g, ''),
// setGmGetValue = callback => getGmValue = callback,
// setGmSetValue = callback => setGmValue = callback,
// setGmDelValue = callback => delGmValue = callback,
// setGmNotice = callback => gmNotice = callback,
// setParentData = obj => pdata = obj,
// arrayInfo = () => console.info(data),
// setLoadedFlag = flag => window.autoSendDanmuModuleLoaded = flag,
// isOldVersion = value => {
// debugger;
// if (!value) {
// return true;
// }
// if (minVersion === value) {
// return false;
// } else {
// let vals = value.split('.');
// let mins = minVersion.split('.');
// if (vals.length != mins.length) {
// return true;
// } else {
// for (let i = 0; i < vals.length; i++) {
// if (mins[i] > vals[i]) {
// return true;
// }
// }
// return false;
// }
// }
// },
// initCss = () => {
// let linkElement = document.createElement('link');
// linkElement.rel = 'stylesheet';
// linkElement.href = 'https://unpkg.com/[email protected]/lib/theme-chalk/index.css';
// document.head.appendChild(linkElement);
// // 图标库 https://ionic.io/ionicons
// // let scriptElement = document.createElement('script');
// // scriptElement.src = 'https://unpkg.com/[email protected]/dist/ionicons.js';
// // document.head.appendChild(scriptElement);
// let customerStyle = document.createElement('style');
// customerStyle.setAttribute('type', 'text/css');
// customerStyle.innerHTML = '.danmu-group-title{font-size:14px;padding-left:2px;color:rgb(18, 56, 141);display:inline;margin-right:60%;vertical-align:middle;}.danmu-group-textarea{width:98%;min-height:100px;height:16%;margin:1px 0px 4px;border:0px;resize:none;}.el-button{display:inline-block;line-height:1;white-space:nowrap;cursor:pointer;background:#FFF;border:1px solid #DCDFE6;color:#606266;-webkit-appearance:none;text-align:center;-webkit-box-sizing:border-box;box-sizing:border-box;outline:0;margin:0;-webkit-transition:.1s;transition:.1s;font-weight:500;padding:12px 20px;font-size:14px;border-radius:4px}.el-button.is-circle{border-radius:50%;padding:12px}.el-button--mini.is-circle{padding:3px;}.el-button:focus,.el-button:hover{color:#409EFF;border-color:#c6e2ff;background-color:#ecf5ff}.el-icon-close.is-circle{padding:5px;color:#ff0000;border:1px solid #ff0000;margin-left:20px;}.el-icon-check.is-circle{padding:5px;color:#0000ff;border:1px solid #0000ff;margin-left:20px;}input[type="checkbox"]{display:none;}.switch-check{display:inline-block;margin:0 5px;vertical-align:middle;}.switch-check-label{display:inline-block;vertical-align:middle;border:1px solid #bdc3c7;border-radius:60px;width:40px;height:18px;position:relative;transition:all .3s;cursor:pointer;}.switch-check-label:before{width:14px;height:14px;content:"";display:inline-block;background-color:#bdc3c7;border-radius:100%;position:absolute;top:2px;left:4px;transition:all .3s;}.switch-check :checked ~ label{background-color:#26b22b;border-color:#26b22b;}.switch-check :checked ~ label:before{left:22px;background-color:#fff;}.danmu-random-setting-panel{background-color:#d4f2e0;border-radius:2px;width:100%;height:100%;overflow-y:auto;position:absolute;left:0px;top:0px;z-index:999;display:none;}.danmu-random-setting-title{text-align:center;font-size:16px;font-weight:700;color:#1c5adc;line-height:30px;}.danmu-random-setting-tips{color:#0b81cc;text-align:center;font-style:italic;}.danmu-random-update-tips{color:#0b81cc;text-align:center;font-size:13px;font-weight:700;margin:10px 0px;}.danmu-random-setting-bottom{width:100%;line-height:35px;}.danmu-random-switch-button-title{font-size:16px;vertical-align:middle;margin-right:4px;color:#095ca2;cursor:help;}.danmu-random-setting-success-tips{text-align:center;display:inline-block;vertical-align:middle;width:34%;}.danmu-random-setting-success-text{font-size:16px;color:#128712;display:none;}.danmu-random-set-button-container{display:inline-block;vertical-align:middle;}';
// document.head.appendChild(customerStyle);
// },
// getCurrentTimestamp = () => new Date().getTime(),
// send = (msg, index) => {
// let dmTextArea = document.getElementById('aside-area-vm').getElementsByClassName('chat-input border-box')[0];
// if (!dmTextArea) {
// alert('找不到输入弹幕文本框,请尝试刷新页面');
// return;
// }
// let btnSend = document.getElementsByClassName('bl-button live-skin-highlight-button-bg live-skin-button-text bl-button--primary bl-button--small')[0];
// if (!btnSend) {
// alert('找不到发送按钮,请尝试刷新页面');
// return;
// }
// // if (getCurrentTimestamp() - lastSent < 5000) {
// // setTimeout(() => send(msg, index), 5000);
// // console.log('===> 发送间隔少于5秒,进入递归处理');
// // } else {
// dmTextArea.value = msg;
// // 定义事件, 定义才可发送
// dmTextArea.dispatchEvent(new Event('input', { "bubbles": true, "cancelable": true }));
// btnSend.click();
// lastSent = getCurrentTimestamp();
// ++count;
// console.log('===> ' + new Date().toLocaleString() + ' 弹幕发送成功 ' + count + ' 次,第【' + index + '】条数据 === ' + msg);
// // }
// },
// isNull = str => {
// if (!str || str == "")
// return true;
// let regu = "^[ ]+$";
// let re = new RegExp(regu);
// return re.test(str);
// },
// randomSort = arr => {
// for (let i = 0; i < arr.length; i++) {
// const rdIndex = Math.floor(Math.random() * arr.length);
// const temp = arr[i];
// arr[i] = arr[rdIndex];
// arr[rdIndex] = temp;
// }
// return arr;
// },
// clearWaiters = () => {
// for (let i = 0; i < waiters.length; i++) {
// workerTimer.clearInterval(waiters[i]);
// waiters[i] = null;
// }
// waiters = [];
// },
// signIn = () => {
// if (signInTimer) {
// workerTimer.clearTimeout(signInTimer);
// signInTimer = null;
// }
// let timestamp = new Date(new Date(new Date().setDate(new Date().getDate() + 1)).toDateString()).getTime() - getCurrentTimestamp();
// console.log('===> 设置凌晨打卡定时器【' + timestamp + '】');
// signInTimer = workerTimer.setTimeout(() => {
// if (dmButtonSend.textContent === '停止')
// send(pdata.signText ? pdata.signText : '打卡', 0);
// console.log('===> 进入下一轮递归签到');
// signIn();
// }, timestamp);
// },
// // selectRandom = () => source.random = rdCheckbox.checked,
// setCheckboxChecked = () => {
// rdCheckbox.checked = source.random;
// group1Checkbox.checked = source.data1.available;
// group2Checkbox.checked = source.data2.available;
// group3Checkbox.checked = source.data3.available;
// group4Checkbox.checked = source.data4.available;
// group5Checkbox.checked = source.data5.available;
// },
// openSetting = () => divSetting.style.display = 'block',
// closeSetting = () => {
// setCheckboxChecked();
// divSetting.style.display = 'none';
// },
// initData = () => {
// if (source.data1.values.length <= 0
// && source.data2.values.length <= 0
// && source.data3.values.length <= 0
// && source.data4.values.length <= 0
// && source.data5.values.length <= 0) {
// return data ? data : [];
// }
// let result = [];
// result = source.data1.available ? result.concat(source.data1.values) : result;
// result = source.data2.available ? result.concat(source.data2.values) : result;
// result = source.data3.available ? result.concat(source.data3.values) : result;
// result = source.data4.available ? result.concat(source.data4.values) : result;
// result = source.data5.available ? result.concat(source.data5.values) : result;
// data = result;
// source.random ? data = randomSort(result) : arrayIndex = 0;
// },
// applySetting = () => {
// source.data1.values = isNull(dataText1.value) ? [] : dataText1.value.split('|');
// source.data2.values = isNull(dataText2.value) ? [] : dataText2.value.split('|');
// source.data3.values = isNull(dataText3.value) ? [] : dataText3.value.split('|');
// source.data4.values = isNull(dataText4.value) ? [] : dataText4.value.split('|');
// source.data5.values = isNull(dataText5.value) ? [] : dataText5.value.split('|');
// source.random = rdCheckbox.checked;
// source.data1.available = group1Checkbox.checked;
// source.data2.available = group2Checkbox.checked;
// source.data3.available = group3Checkbox.checked;
// source.data4.available = group4Checkbox.checked;
// source.data5.available = group5Checkbox.checked;
// initData();
// setGmValue(roomId, source);
// spanApplyTip.style.display = 'block';
// setTimeout(() => {
// spanApplyTip.style.display = 'none';
// divSetting.style.display = 'none';
// }, 1500);
// },
// danmu = () => {
// if (data.length < 1) {
// // alert('请任意在一个分组里输入一条弹幕');
// gmNotice({
// text: '请任意在一个分组里输入一条弹幕',
// title: '没有弹幕数据,请先设置',
// image: icoUrl,
// highlight: true,
// timeout: noticeTimeout
// });
// return false;
// }
// if (source.random)
// arrayIndex = Math.floor((Math.random() * data.length));
// send(data[arrayIndex], arrayIndex);
// ++arrayIndex;
// if (arrayIndex >= data.length)
// arrayIndex = 0;
// return true;
// },
// offOrOn = () => {
// let timeout = 0;
// if (sendTimer) {
// workerTimer.clearInterval(sendTimer);
// sendTimer = null;
// dmButtonSend.style.background = 'rgba(217,157,27,1)';
// dmButtonSend.textContent = '开始';
// dmInput.removeAttribute("disabled");
// } else {
// timeout = isNull(dmInput.value) ? default_timeout * 1000 : dmInput.value * 1000;
// if (!danmu())
// return;
// sendTimer = workerTimer.setInterval(danmu, timeout);
// dmButtonSend.style.background = '#ff0000';
// dmButtonSend.textContent = '停止';
// dmInput.setAttribute('disabled', 'disabled');
// }
// },
// buildPanel = divButton => {
// /* ----------------------------------------- head ----------------------------------------- */
// let divSettingTitle = document.createElement('div');
// divSettingTitle.textContent = '弹幕设置';
// divSettingTitle.classList.add('danmu-random-setting-title');
// let divTip = document.createElement('div');
// divTip.classList.add('danmu-random-setting-tips');
// divTip.innerHTML = '任一分组内输入弹幕即可,多条用<span style="color:#dc6b07;margin:0 2px 0 4px;font-weight:700;font-style:normal;">竖线</span>分隔';
// let divUpdateTip = document.createElement('div');
// divUpdateTip.classList.add('danmu-random-update-tips');
// divUpdateTip.innerHTML = '<span style="color:#f00">更新提示:</span>近期油猴网络不稳影响脚本加载';
// /* ----------------------------------------- head ----------------------------------------- */
// /* ----------------------------------------- textarea 1 ----------------------------------------- */
// let divText1 = document.createElement('div');
// divText1.textContent = '分组 1 :';
// divText1.classList.add('danmu-group-title');
// group1Checkbox = document.createElement('input');
// group1Checkbox.type = 'checkbox';
// group1Checkbox.id = 'group1Checkbox';
// group1Checkbox.checked = true;
// let lblGroup1Checkbox = document.createElement('label');
// lblGroup1Checkbox.setAttribute('for', 'group1Checkbox');
// lblGroup1Checkbox.classList.add('switch-check-label');
// let divGroup1Checkbox = document.createElement('div');
// divGroup1Checkbox.classList.add('switch-check');
// divGroup1Checkbox.appendChild(group1Checkbox);
// divGroup1Checkbox.appendChild(lblGroup1Checkbox);
// dataText1 = document.createElement('textarea');
// dataText1.classList.add('danmu-group-textarea');
// dataText1.setAttribute('placeholder', '请输入弹幕,多条弹幕请用“|”分隔');
// /* ----------------------------------------- textarea 1 ----------------------------------------- */
// /* ----------------------------------------- textarea 2 ----------------------------------------- */
// let divText2 = document.createElement('div');
// divText2.textContent = '分组 2 :';
// divText2.classList.add('danmu-group-title');
// group2Checkbox = document.createElement('input');
// group2Checkbox.type = 'checkbox';
// group2Checkbox.id = 'group2Checkbox';
// group2Checkbox.checked = true;
// let lblGroup2Checkbox = document.createElement('label');
// lblGroup2Checkbox.setAttribute('for', 'group2Checkbox');
// lblGroup2Checkbox.classList.add('switch-check-label');
// let divGroup2Checkbox = document.createElement('div');
// divGroup2Checkbox.classList.add('switch-check');
// divGroup2Checkbox.appendChild(group2Checkbox);
// divGroup2Checkbox.appendChild(lblGroup2Checkbox);
// dataText2 = document.createElement('textarea');
// dataText2.classList.add('danmu-group-textarea');
// dataText2.setAttribute('placeholder', '请输入弹幕,多条弹幕请用“|”分隔');
// /* ----------------------------------------- textarea 2 ----------------------------------------- */
// /* ----------------------------------------- textarea 3 ----------------------------------------- */
// let divText3 = document.createElement('div');
// divText3.textContent = '分组 3 :';
// divText3.classList.add('danmu-group-title');
// group3Checkbox = document.createElement('input');
// group3Checkbox.type = 'checkbox';
// group3Checkbox.id = 'group3Checkbox';
// group3Checkbox.checked = true;
// let lblGroup3Checkbox = document.createElement('label');
// lblGroup3Checkbox.setAttribute('for', 'group3Checkbox');
// lblGroup3Checkbox.classList.add('switch-check-label');
// let divGroup3Checkbox = document.createElement('div');
// divGroup3Checkbox.classList.add('switch-check');
// divGroup3Checkbox.appendChild(group3Checkbox);
// divGroup3Checkbox.appendChild(lblGroup3Checkbox);
// dataText3 = document.createElement('textarea');
// dataText3.classList.add('danmu-group-textarea');
// dataText3.setAttribute('placeholder', '请输入弹幕,多条弹幕请用“|”分隔');
// /* ----------------------------------------- textarea 3 ----------------------------------------- */
// /* ----------------------------------------- textarea 4 ----------------------------------------- */
// let divText4 = document.createElement('div');
// divText4.textContent = '分组 4 :';
// divText4.classList.add('danmu-group-title');
// group4Checkbox = document.createElement('input');
// group4Checkbox.type = 'checkbox';
// group4Checkbox.id = 'group4Checkbox';
// group4Checkbox.checked = true;
// let lblGroup4Checkbox = document.createElement('label');
// lblGroup4Checkbox.setAttribute('for', 'group4Checkbox');
// lblGroup4Checkbox.classList.add('switch-check-label');
// let divGroup4Checkbox = document.createElement('div');
// divGroup4Checkbox.classList.add('switch-check');
// divGroup4Checkbox.appendChild(group4Checkbox);
// divGroup4Checkbox.appendChild(lblGroup4Checkbox);
// dataText4 = document.createElement('textarea');
// dataText4.classList.add('danmu-group-textarea');
// dataText4.setAttribute('placeholder', '请输入弹幕,多条弹幕请用“|”分隔');
// /* ----------------------------------------- textarea 4 ----------------------------------------- */
// /* ----------------------------------------- textarea 5 ----------------------------------------- */
// let divText5 = document.createElement('div');
// divText5.textContent = '分组 5 :';
// divText5.classList.add('danmu-group-title');
// group5Checkbox = document.createElement('input');
// group5Checkbox.type = 'checkbox';
// group5Checkbox.id = 'group5Checkbox';
// group5Checkbox.checked = true;
// let lblGroup5Checkbox = document.createElement('label');
// lblGroup5Checkbox.setAttribute('for', 'group5Checkbox');
// lblGroup5Checkbox.classList.add('switch-check-label');
// let divGroup5Checkbox = document.createElement('div');
// divGroup5Checkbox.classList.add('switch-check');
// divGroup5Checkbox.appendChild(group5Checkbox);
// divGroup5Checkbox.appendChild(lblGroup5Checkbox);
// dataText5 = document.createElement('textarea');
// dataText5.classList.add('danmu-group-textarea');
// dataText5.setAttribute('placeholder', '请输入弹幕,多条弹幕请用“|”分隔');
// /* ----------------------------------------- textarea 5 ----------------------------------------- */
// /* ----------------------------------------- random chackbox ----------------------------------------- */
// let descCheckbox = document.createElement('span');
// descCheckbox.textContent = '随机';
// descCheckbox.title = '将合并所有分组数据,从中随机选出一条发送';
// descCheckbox.classList.add('danmu-random-switch-button-title');
// rdCheckbox = document.createElement('input');
// rdCheckbox.type = 'checkbox';
// rdCheckbox.id = 'rdmCheckbox';
// rdCheckbox.checked = true;
// // rdCheckbox.addEventListener('click', selectRandom);
// let lblCheckbox = document.createElement('label');
// lblCheckbox.setAttribute('for', 'rdmCheckbox');
// lblCheckbox.classList.add('switch-check-label');
// let divCheckbox = document.createElement('div');
// divCheckbox.classList.add('switch-check');
// divCheckbox.style.marginLeft = '10px';
// divCheckbox.appendChild(descCheckbox);
// divCheckbox.appendChild(rdCheckbox);
// divCheckbox.appendChild(lblCheckbox);
// /* ----------------------------------------- random chackbox ----------------------------------------- */
// /* ----------------------------------------- div tip ----------------------------------------- */
// spanApplyTip = document.createElement('span');
// spanApplyTip.textContent = '设置成功';
// spanApplyTip.classList.add('danmu-random-setting-success-text');
// let divApplyTip = document.createElement('div');
// divApplyTip.classList.add('danmu-random-setting-success-tips');
// divApplyTip.appendChild(spanApplyTip);
// /* ----------------------------------------- div tip ----------------------------------------- */
// /* ----------------------------------------- appley and close button ----------------------------------------- */
// let btnApplySetting = document.createElement('i');
// btnApplySetting.setAttribute('title', '应用');
// btnApplySetting.classList.add('el-button');
// btnApplySetting.classList.add('el-icon-check');
// btnApplySetting.classList.add('is-circle');
// btnApplySetting.addEventListener('click', applySetting);
// let btnCloseSetting = document.createElement('i');
// btnCloseSetting.setAttribute('title', '关闭');
// btnCloseSetting.classList.add('el-button');
// btnCloseSetting.classList.add('el-icon-close');
// btnCloseSetting.classList.add('is-circle');
// btnCloseSetting.addEventListener('click', closeSetting);
// let divSettingButton = document.createElement('div');
// divSettingButton.classList.add('danmu-random-set-button-container');
// divSettingButton.appendChild(btnApplySetting);
// divSettingButton.appendChild(btnCloseSetting);
// /* ----------------------------------------- appley and close button ----------------------------------------- */
// /* ----------------------------------------- container ----------------------------------------- */
// let divBottomContainer = document.createElement('div');
// divBottomContainer.classList.add('danmu-random-setting-bottom');
// divBottomContainer.appendChild(divCheckbox);
// divBottomContainer.appendChild(divApplyTip);
// divBottomContainer.appendChild(divSettingButton);
// let divContainer = document.createElement('div');
// divContainer.style.height = 'calc(98% - 30px - 25px)';
// divContainer.appendChild(divText1);
// divContainer.appendChild(divGroup1Checkbox);
// divContainer.appendChild(dataText1);
// divContainer.appendChild(divText2);
// divContainer.appendChild(divGroup2Checkbox);
// divContainer.appendChild(dataText2);
// divContainer.appendChild(divText3);
// divContainer.appendChild(divGroup3Checkbox);
// divContainer.appendChild(dataText3);
// divContainer.appendChild(divText4);
// divContainer.appendChild(divGroup4Checkbox);
// divContainer.appendChild(dataText4);
// divContainer.appendChild(divText5);
// divContainer.appendChild(divGroup5Checkbox);
// divContainer.appendChild(dataText5);
// divContainer.appendChild(divBottomContainer);
// /* ----------------------------------------- container ----------------------------------------- */
// divSetting = document.createElement('div');
// divSetting.id = 'danmu-setting-panel';
// divSetting.classList.add('danmu-random-setting-panel');
// divSetting.appendChild(divSettingTitle);
// divSetting.appendChild(divTip);
// divSetting.appendChild(divUpdateTip);
// divSetting.appendChild(divContainer);
// let asideAreaVm = document.getElementById('aside-area-vm');
// asideAreaVm.appendChild(divSetting);
// /* ----------------------------------------- function ----------------------------------------- */
// dmButtonSend = document.createElement('button');
// dmButtonSend.textContent = '开始';
// dmButtonSend.style.minWidth = '65px';
// dmButtonSend.style.height = '24px';
// dmButtonSend.style.fontSize = '12px';
// dmButtonSend.style.borderRadius = '4px';
// dmButtonSend.style.color = '#ffffff';
// dmButtonSend.style.background = 'rgba(217,157,27,1)';
// dmButtonSend.style.border = '0';
// dmButtonSend.style.cursor = 'pointer';
// //dmButtonSend.onclick = function() { alert('Hello world');}
// dmButtonSend.addEventListener('click', offOrOn);
// let beforeSpan = document.createElement('span');
// beforeSpan.textContent = '每';
// beforeSpan.style.color = '#ffffff';
// beforeSpan.style.fontSize = '12px';
// beforeSpan.style.marginLeft = '4px';
// beforeSpan.style.backgroundColor = '#ec6c1b';
// dmInput = document.createElement('input');
// dmInput.value = default_timeout;
// dmInput.style.width = '25px';
// dmInput.style.height = '15px';
// dmInput.style.margin = '0 3px';
// dmInput.style.border = '0';
// dmInput.style.borderRadius = '3px';
// dmInput.setAttribute('oninput', "this.value = this.value.replace(/[^0-9]/g, '')");
// let afterSpan = document.createElement('span');
// afterSpan.textContent = '秒发送';
// afterSpan.style.color = '#ffffff';
// afterSpan.style.fontSize = '12px';
// afterSpan.style.backgroundColor = '#ec6c1b';
// afterSpan.style.marginRight = '4px';
// let iElement = document.createElement('i');
// iElement.classList.add('el-icon-setting');
// let btnSetting = document.createElement('button');
// btnSetting.title = '设置';
// btnSetting.classList.add('el-button');
// btnSetting.classList.add('el-button--mini');
// btnSetting.classList.add('is-circle');
// btnSetting.addEventListener('click', openSetting);
// btnSetting.appendChild(iElement);
// // let btnSetting = document.createElement('ion-icon');
// // btnSetting.setAttribute('name', 'settings-sharp');
// // btnSetting.classList.add('el-button');
// // btnSetting.classList.add('el-button--mini');
// // btnSetting.classList.add('is-circle');
// // btnSetting.addEventListener('click', openSetting);
// let div = document.createElement('div');
// div.style.position = 'absolute';
// div.appendChild(dmButtonSend);
// div.appendChild(beforeSpan);
// div.appendChild(dmInput);
// div.appendChild(afterSpan);
// div.appendChild(btnSetting);
// divButton.appendChild(div);
// /* ----------------------------------------- function ----------------------------------------- */
// },
// removeElements = () => {
// let switchLoginGuideVm = document.getElementById('switch-login-guide-vm');
// if (switchLoginGuideVm)
// switchLoginGuideVm.style.setProperty('display', 'none', 'important');
// let myDearHarunaVm = document.getElementById('my-dear-haruna-vm');
// if (myDearHarunaVm)
// myDearHarunaVm.style.setProperty('display', 'none', 'important');
// let shopPopoverVm = document.getElementById('shop-popover-vm');
// if (shopPopoverVm)
// shopPopoverVm.style.setProperty('display', 'none', 'important');
// if (removeElementsTimer) {
// workerTimer.clearInterval(removeElementsTimer);
// removeElementsTimer = null;
// }
// removeElementsTimer = workerTimer.setInterval(() => {
// ++removeElementsTimerCount;
// let ltRow = document.getElementsByClassName('lt-row')[0];
// if (ltRow) {
// ltRow.style.setProperty('display', 'none', 'important');
// if (removeElementsTimer) {
// workerTimer.clearInterval(removeElementsTimer);
// removeElementsTimer = null;
// }
// }
// if (30 <= removeElementsTimerCount && removeElementsTimer) {
// workerTimer.clearInterval(removeElementsTimer);
// removeElementsTimer = null;
// }
// }, 10000);
// },
// loadData = () => {
// let obj = getGmValue(roomId, null);
// if (obj) {
// if (source.version === obj.version) {
// source = obj;
// }
// else if (obj.version === 2) {
// source.data1 = obj.data1;
// source.data2 = obj.data2;
// source.data3 = obj.data3;
// source.data4 = obj.data4;
// source.data5 = obj.data5;
// setGmValue(roomId, source);
// } else {
// source.data1.values = obj.data1 ? obj.data1 : source.data1.values;
// source.data2.values = obj.data2 ? obj.data2 : source.data2.values;
// source.data3.values = obj.data3 ? obj.data3 : source.data3.values;
// source.data4.values = obj.data4 ? obj.data4 : source.data4.values;
// source.data5.values = obj.data5 ? obj.data5 : source.data5.values;
// setGmValue(roomId, source);
// }
// }
// setCheckboxChecked();
// dataText1.value = source.data1.values.join('|');
// dataText2.value = source.data2.values.join('|');
// dataText3.value = source.data3.values.join('|');
// dataText4.value = source.data4.values.join('|');
// dataText5.value = source.data5.values.join('|');
// initData();
// },
// initSettingPanel = () => {
// let settingPanel = document.getElementById('danmu-setting-panel');
// if (!settingPanel) {
// console.log('===> 进行初始化弹幕设置界面');
// let divButton = document.getElementsByClassName('bottom-actions p-relative')[0];
// if (divButton) {
// clearWaiters();
// buildPanel(divButton);
// loadData();
// setLoadedFlag(true);
// console.log('===> 弹幕设置界面初始化完成');
// } else {
// console.warn('===> 页面改版,所属元数丢失');
// return;
// }
// }
// },
// runStart = () => {
// initSettingPanel();
// removeElements();
// signIn();
// };
debugger;
window.runStart = runStart;
window.arrayInfo = arrayInfo;
window.setGmNotice = setGmNotice;
window.setGmGetValue = setGmGetValue;
window.setGmSetValue = setGmSetValue;
window.setGmDelValue = setGmDelValue;
window.setParentData = setParentData;
// initCss();
// window.addEventListener("load", () => {
// console.log('===> 打印组件id ' + pdata.moduleId);
// debugger;
// let script = document.getElementById(pdata.moduleId);
// if (script) {
// if (isOldVersion(script.version)) {
// alert('11111111发随机弹幕脚本需 >=' + minVersion + ' 版本,请及时更新');
// window.location.href = parentUrl;
// return;
// }
// } else {
// // setLoadedFlag(true);
// // workerTimer.setTimeout(() => {
// alert('22222222发随机弹幕脚本需 >=' + minVersion + ' 版本,请及时更新');
// window.location.href = parentUrl;
// // gmNotice({
// // text: '当前脚本不是最新版,请更新再使用功能',
// // title: '油猴脚本有更新,点击进行安装',
// // image: icoUrl,
// // highlight: true,
// // timeout: 120000,
// // onclick: () => window.open(parentUrl, '_blank')
// // });
// // }, 1000);
// return;
// }
// waiters[waiters.length] = workerTimer.setInterval(() => {
// debugger;
// initSettingPanel();
// --waitCount;
// if (0 >= waitCount) {
// setLoadedFlag(true);
// clearWaiters();
// console.log('===> 建立设置面板失败,停止初始化');
// // debugger;
// // gmNotice({
// // text: '没能找到发送按钮的所属元素,请刷新重试',
// // title: '加载错误,点击刷新页面',
// // image: icoUrl,
// // highlight: true,
// // timeout: noticeTimeout,
// // onclick: () => location.reload()
// // });
// }
// }, 1500);
// });
})();