// ==UserScript==
// @name B站直播间SC记录板
// @namespace http://tampermonkey.net/
// @homepage https://greasyfork.org/zh-CN/scripts/484381
// @version 9.2.0
// @description 实时同步SC、同接、高能和舰长数据,可拖拽移动,可导出,可单个SC折叠,可侧折,可记忆配置,可生成图片(右键菜单),活动页可用,黑名单功能,不用登录,多种主题切换,直播全屏也在顶层显示,自动清除超过12小时的房间SC存储
// @author ltxlong
// @match *://live.bilibili.com/1*
// @match *://live.bilibili.com/2*
// @match *://live.bilibili.com/3*
// @match *://live.bilibili.com/4*
// @match *://live.bilibili.com/5*
// @match *://live.bilibili.com/6*
// @match *://live.bilibili.com/7*
// @match *://live.bilibili.com/8*
// @match *://live.bilibili.com/9*
// @match *://live.bilibili.com/blanc/1*
// @match *://live.bilibili.com/blanc/2*
// @match *://live.bilibili.com/blanc/3*
// @match *://live.bilibili.com/blanc/4*
// @match *://live.bilibili.com/blanc/5*
// @match *://live.bilibili.com/blanc/6*
// @match *://live.bilibili.com/blanc/7*
// @match *://live.bilibili.com/blanc/8*
// @match *://live.bilibili.com/blanc/9*
// @icon https://www.bilibili.com/favicon.ico
// @require https://cdn.bootcdn.net/ajax/libs/jquery/3.7.1/jquery.min.js
// @require https://cdn.bootcdn.net/ajax/libs/html2canvas/1.4.1/html2canvas.min.js
// @grant unsafeWindow
// @grant GM_registerMenuCommand
// @license GPL-3.0-or-later
// @downloadURL none
// ==/UserScript==
(function() {
'use strict';
function sc_catch_log(...msg) {
console.log('%c[sc_catch]', 'font-weight: bold; color: white; background-color: #A7C9D3; padding: 2px; border-radius: 2px;', ...msg);
}
// 抓取SC :https://api.live.bilibili.com/xlive/web-room/v1/index/getInfoByRoom?room_id=
// 进入直播间的时候开始记录SC
// 开始固定在屏幕左上方一侧,为圆形小图标,可以点击展开,可以拖拽移动,活动页可用,直播全屏也在顶层显示
// 通过Hook实时抓取数据
// 每个直播间隔离保留,用localstorage,并且自动清理时间长的数据
// SC标明发送时间和距离当前的时间差
// SC可折叠,可生成图片(折叠和展开都可以)
// 黑名单功能
// 右键菜单功能
// 侧折模式功能
// 记忆模式选择功能
// 记忆模式说明:
// 没记:没有记忆配置
// 题记:只记忆主题,所有<题记>房间共用一个主题配置
// 个记:独立记忆当前房间的所有配置
// 全记:所有的房间共用的记忆配置
// 记忆的优先级:
// 全记 > 个记 > 题记
// 进入直播房间的时候会依次检查优先级,来进行自动加载配置
// 例子说明:
// 有四个直播房间:
// A、B、C、D
// 已经打开:A[题记],B[个记]
// 现在打开C房间,会从[全记]->[个记]->[题记]依次检查,都没有则默认是[没记]。
// 当C从[没记]切换到[题记]时,如果[题记]存在记忆的主题,C的主题会自动切换到[题记]记忆的主题,当C切换主题时候,会更新[题记]记忆的主题
// 这个时候,虽然A和C都是[题记]模式,但是主题却不一样,其中C的主题才是[题记]记忆的最新主题,当A页面刷新后,会变为[题记]最新记忆的主题
// 当C从[题记]切换到[个记],[题记]的房间中剔除C,并且C会立即生成自己的独立配置,处于[个记]模式下,C的所有配置操作都会独立记忆
// 当C从[个记]切换到[全记],C的[个记]独立配置会立即删除,并且会将自己的所有配置生成[全记]的配置,如果这个时候,A、B页面刷新,会自动加载[全记]的配置
// 现在打开D房间,由于已经存在[全记]的配置,所以D会自动加载[全记]的配置。
// 如果这个时候,D从[全记]切换到[没记],那么所有页面的[全记]都会失效,最多30秒后,其余[全记]页面的按钮会变为[没记](因为每30秒检查一次)
// 刷新A、B页面,A会自动加载[题记], B会自动加载[个记],即都会恢复为被[全记]影响之前的配置模式
// 总结:
// [个记]的删除时机:从[个记]点击按钮,手动切换到[全记]
// [全记]的删除时机:从[全记]点击按钮,手动切换到[没记]
// [题记]和[全记]的区别:
// [题记]是一个小圈子,这个圈子有自己的主题颜色,每个房间都可以加入其中,切换加入的时候,该房间会被动的染上圈子的主题颜色,并且也有权限改变圈子的颜色
// [全记]是一个全局权限,当有一个房间切换到[全记]时,即拿到了这个全局权限,并且复制自己的所有配置附加在上面,
// 后续每一个新进入/刷新的房间都会自动获得这个全局权限并且自动加载上面的配置,
// 当其中一个房间从[全记]模式切换到[没记]的时候,这个全局权限就会失效,最多30秒后,其余[全记]页面的按钮会变为[没记](因为每30秒检查一次),其余房间刷新页面会恢复被[全记]影响之前的配置模式
let room_id = unsafeWindow.location.pathname.split('/').pop();
let sc_url_api = 'https://api.live.bilibili.com/xlive/web-room/v1/index/getInfoByRoom?room_id=';
sc_catch_log('url_room_id:', room_id);
if (!room_id) { sc_catch_log('获取room_id失败,插件已停止正确的SC存储'); }
let sc_url = sc_url_api + room_id; // 请求sc的url
let sc_panel_list_height = 400; // 显示面板的最大高度(单位是px,后面会拼接)
let sc_rectangle_width = 302; // 默认302,右侧合适325/388/428(SC刚刚好在弹幕框内/侧折模式记录板紧贴在弹幕框右侧外/侧折模式记录板紧贴在屏幕右侧)
let data_show_top_flag = true; // 是否在页面右侧弹幕滚动框的顶部动态显示数据
let data_show_bottom_flag = true; // 是否在页面右侧弹幕滚动框的底部动态显示数据
let sc_localstorage_key = 'live_' + room_id + '_sc';
let sc_sid_localstorage_key = 'live_' + room_id + '_sc_sid';
let sc_live_room_title = '';
let sc_keep_time_key = 'live_' + room_id + '_sc_keep_time';
let sc_clear_time_hour = 12; // 大于sc_clear_time_hour(默认12)小时即清除上一次的存储(会自动遍历检测所有存储的房间)
let sc_now_time = (new Date()).getTime();
let sc_keep_time = unsafeWindow.localStorage.getItem(sc_keep_time_key);
let sc_keep_time_flag = 0;
let high_energy_num = 0;
let sc_update_date_guard_once = false;
let sc_room_blacklist_flag = false;
// 0-侧折模式下显示所有的按钮
// 1-侧折模式下隐藏所有的按钮
// 2-侧折模式下按钮的极简模式(只显示菜单和折叠按钮)
// 3-侧折模式下只显示折叠按钮
// 4-侧折模式下只显示菜单按钮
let sc_func_btn_mode = 0;
let sc_panel_allow_drag_flag = true; // 是否可以拖拽
let sc_side_fold_custom_config = 0; // 侧折模式的自定义:0-默认,1-第一个展开,2-第一个展开时间自定义
let sc_side_fold_custom_time = 0;
let sc_side_fold_custom_first_class = '';
let sc_side_fold_custom_first_timeout_id = '';
let sc_start_time_show_flag = true; //是否显示SC发送的具体时间
let sc_welt_hide_circle_half_flag = false; // 是否小图标贴边半隐藏
let sc_side_fold_custom_each_same_time_flag = false; // 是否每个实时SC都有相同的展开时间
let sc_side_fold_custom_each_same_time_class = '';
let sc_side_fold_custom_each_same_time_timeout_id = '';
let sc_side_fold_custom_auto_run_flag = false; // 是否在运行自动展现SC了
let sc_side_fold_custom_stop_from_auto_flag = false; // 是否自动运行时间到的停止
let sc_memory = 0; // 0-没记,1-题记,2-个记,3-全记
let sc_switch = 0;
let sc_panel_fold_mode = 0; // 0-最小化,1-侧折,2-展开
let sc_panel_side_fold_simple = false; // 侧折的极简模式
let sc_panel_drag_left = -1;
let sc_panel_drag_top = -1;
let sc_panel_side_fold_flag = false; // 侧折
let sc_item_side_fold_touch_flag = false;
let sc_item_side_fold_touch_oj = {};
let sc_self_memory_config_key = 'live_' + room_id + '_sc_self_memory_config';
let sc_isDragging = false;
let sc_isClickAllowed = true;
let sc_drag_start = 0; // 兼容有的时候点击触发拖拽的情况
let sc_offsetX = 0;
let sc_offsetY = 0;
let sc_isListEmpty = true;
let sc_isFullscreen = false;
let sc_rectangle_is_slide_down = false;
let sc_rectangle_is_slide_up = false;
let sc_rectangle_mouse_out = true;
let sc_live_sidebar_left_flag = false; // 是否设置直播间的右侧滑动按钮在左侧
let sc_item_order_up_flag = false; // 是否设置SC的排列顺序是从下往上(最新的在底部)
function sc_memory_get_store_mode_all(sc_all_memory_config_json) {
let sc_all_memory_config = JSON.parse(sc_all_memory_config_json);
sc_switch = sc_all_memory_config['sc_switch'] ?? 0;
sc_panel_fold_mode = sc_all_memory_config['sc_panel_fold_mode'] ?? 0;
sc_panel_side_fold_flag = sc_all_memory_config['sc_panel_side_fold_flag'] ?? false;
sc_panel_side_fold_simple = sc_all_memory_config['sc_panel_side_fold_simple'] ?? false;
sc_panel_drag_left = sc_all_memory_config['sc_panel_drag_left'] ?? -1;
sc_panel_drag_top = sc_all_memory_config['sc_panel_drag_top'] ?? -1;
sc_func_btn_mode = sc_all_memory_config['sc_func_btn_mode'] ?? 0;
data_show_bottom_flag = sc_all_memory_config['data_show_bottom_flag'] ?? true;
sc_panel_allow_drag_flag = sc_all_memory_config['sc_panel_allow_drag_flag'] ?? true;
sc_side_fold_custom_config = sc_all_memory_config['sc_side_fold_custom_config'] ?? 0;
sc_side_fold_custom_time = sc_all_memory_config['sc_side_fold_custom_time'] ?? 10;
sc_start_time_show_flag = sc_all_memory_config['sc_start_time_show_flag'] ?? true;
sc_welt_hide_circle_half_flag = sc_all_memory_config['sc_welt_hide_circle_half_flag'] ?? false;
sc_side_fold_custom_each_same_time_flag = sc_all_memory_config['sc_side_fold_custom_each_same_time_flag'] ?? false;
sc_rectangle_width = sc_all_memory_config['sc_rectangle_width'] ?? 302;
sc_panel_list_height = sc_all_memory_config['sc_panel_list_height'] ?? 400;
sc_live_sidebar_left_flag = sc_all_memory_config['sc_live_sidebar_left_flag'] ?? false;
sc_item_order_up_flag = sc_all_memory_config['sc_item_order_up_flag'] ?? false;
if (sc_panel_fold_mode === 1 && (unsafeWindow.innerWidth - sc_panel_drag_left) < 72) {
sc_panel_drag_left = unsafeWindow.innerWidth - 72;
}
if (sc_panel_fold_mode === 2 && (unsafeWindow.innerWidth - sc_panel_drag_left) < sc_rectangle_width) {
sc_panel_drag_left = unsafeWindow.innerWidth - sc_rectangle_width;
}
if (sc_panel_drag_top <= 0) {
sc_panel_drag_top = 0;
}
if (sc_panel_drag_top >= unsafeWindow.innerHeight) {
sc_panel_drag_top = unsafeWindow.innerHeight - sc_panel_list_height;
}
}
function sc_memory_get_store_mode_self(sc_self_memory_config_json) {
let sc_self_memory_config = JSON.parse(sc_self_memory_config_json);
sc_switch = sc_self_memory_config['sc_switch'] ?? 0;
sc_panel_fold_mode = sc_self_memory_config['sc_panel_fold_mode'] ?? 0;
sc_panel_side_fold_flag = sc_self_memory_config['sc_panel_side_fold_flag'] ?? false;
sc_panel_side_fold_simple = sc_self_memory_config['sc_panel_side_fold_simple'] ?? false;
sc_panel_drag_left = sc_self_memory_config['sc_panel_drag_left'] ?? -1;
sc_panel_drag_top = sc_self_memory_config['sc_panel_drag_top'] ?? -1;
sc_func_btn_mode = sc_self_memory_config['sc_func_btn_mode'] ?? 0;
data_show_bottom_flag = sc_self_memory_config['data_show_bottom_flag'] ?? true;
sc_panel_allow_drag_flag = sc_self_memory_config['sc_panel_allow_drag_flag'] ?? true;
sc_side_fold_custom_config = sc_self_memory_config['sc_side_fold_custom_config'] ?? 0;
sc_side_fold_custom_time = sc_self_memory_config['sc_side_fold_custom_time'] ?? 10;
sc_start_time_show_flag = sc_self_memory_config['sc_start_time_show_flag'] ?? true;
sc_welt_hide_circle_half_flag = sc_self_memory_config['sc_welt_hide_circle_half_flag'] ?? false;
sc_side_fold_custom_each_same_time_flag = sc_self_memory_config['sc_side_fold_custom_each_same_time_flag'] ?? false;
sc_rectangle_width = sc_self_memory_config['sc_rectangle_width'] ?? 302;
sc_panel_list_height = sc_self_memory_config['sc_panel_list_height'] ?? 400;
sc_live_sidebar_left_flag = sc_self_memory_config['sc_live_sidebar_left_flag'] ?? false;
sc_item_order_up_flag = sc_self_memory_config['sc_item_order_up_flag'] ?? false;
if (sc_panel_fold_mode === 1 && (unsafeWindow.innerWidth - sc_panel_drag_left) < 72) {
sc_panel_drag_left = unsafeWindow.innerWidth - 72;
}
if (sc_panel_fold_mode === 2 && (unsafeWindow.innerWidth - sc_panel_drag_left) < sc_rectangle_width) {
sc_panel_drag_left = unsafeWindow.innerWidth - sc_rectangle_width;
}
if (sc_panel_drag_top <= 0) {
sc_panel_drag_top = 0;
}
if (sc_panel_drag_top >= unsafeWindow.innerHeight) {
sc_panel_drag_top = unsafeWindow.innerHeight - sc_panel_list_height;
}
sc_memory = 2;
}
function sc_memory_get_store_mode_switch(sc_switch_memory_rooms_json) {
let sc_switch_memory_rooms = JSON.parse(sc_switch_memory_rooms_json);
if (sc_switch_memory_rooms.includes(room_id)) {
let sc_switch_record = unsafeWindow.localStorage.getItem('live_sc_switch_record');
if (sc_switch_record !== null && sc_switch_record !== 'null' && sc_switch_record !== '') {
sc_switch = parseInt(sc_switch_record, 10);
}
sc_memory = 1;
}
}
// 记忆配置检查
// 优先级:3-全记 > 2-个记 > 1-题记
let sc_memory_all_rooms_mode = unsafeWindow.localStorage.getItem('live_sc_memory_all_rooms_mode');
if (sc_memory_all_rooms_mode !== null && sc_memory_all_rooms_mode !== 'null' && sc_memory_all_rooms_mode !== '') {
sc_memory = parseInt(sc_memory_all_rooms_mode, 10);
// sc_memory_all_rooms_mode的值目前只能是3-全记
if (sc_memory !== 3) {
sc_memory = 0;
}
if (sc_memory === 3) {
// 全记
let sc_all_memory_config_json = unsafeWindow.localStorage.getItem('live_sc_all_memory_config');
if (sc_all_memory_config_json !== null && sc_all_memory_config_json !== 'null' && sc_all_memory_config_json !== '[]' && sc_all_memory_config_json !== '{}' && sc_all_memory_config_json !== '') {
sc_memory_get_store_mode_all(sc_all_memory_config_json);
}
} else {
// 个记
let sc_self_memory_config_json = unsafeWindow.localStorage.getItem(sc_self_memory_config_key);
if (sc_self_memory_config_json !== null && sc_self_memory_config_json !== 'null' && sc_self_memory_config_json !== '[]' && sc_self_memory_config_json !== '{}' && sc_self_memory_config_json !== '') {
sc_memory_get_store_mode_self(sc_self_memory_config_json);
} else {
// 题记
let sc_switch_memory_rooms_json = unsafeWindow.localStorage.getItem('live_sc_switch_memory_rooms');
if (sc_switch_memory_rooms_json !== null && sc_switch_memory_rooms_json !== 'null' && sc_switch_memory_rooms_json !== '[]' && sc_switch_memory_rooms_json !== '') {
sc_memory_get_store_mode_switch(sc_switch_memory_rooms_json);
}
}
}
} else {
// 个记
let sc_self_memory_config_json = unsafeWindow.localStorage.getItem(sc_self_memory_config_key);
if (sc_self_memory_config_json !== null && sc_self_memory_config_json !== 'null' && sc_self_memory_config_json !== '[]' && sc_self_memory_config_json !== '{}' && sc_self_memory_config_json !== '') {
sc_memory_get_store_mode_self(sc_self_memory_config_json);
} else {
// 题记
let sc_switch_memory_rooms_json = unsafeWindow.localStorage.getItem('live_sc_switch_memory_rooms');
if (sc_switch_memory_rooms_json !== null && sc_switch_memory_rooms_json !== 'null' && sc_switch_memory_rooms_json !== '[]' && sc_switch_memory_rooms_json !== '') {
sc_memory_get_store_mode_switch(sc_switch_memory_rooms_json);
}
}
}
if (sc_keep_time !== null && sc_keep_time !== 'null' && sc_keep_time !== 0 && sc_keep_time !== '') {
sc_keep_time_flag = 1;
}
// 先检测并处理本房间的
if (sc_keep_time_flag && (sc_now_time - sc_keep_time) > 1000 * 60 * 60 * sc_clear_time_hour) {
unsafeWindow.localStorage.removeItem(sc_localstorage_key);
unsafeWindow.localStorage.removeItem(sc_sid_localstorage_key);
}
function check_and_clear_all_sc_store() {
// 遍历清除所有过期的sc存储
let live_sc_rooms_json = unsafeWindow.localStorage.getItem('live_sc_rooms');
if (live_sc_rooms_json !== null && live_sc_rooms_json !== 'null' && live_sc_rooms_json !== '[]' && live_sc_rooms_json !== '') {
let live_sc_rooms = JSON.parse(live_sc_rooms_json);
let live_sc_rooms_new = [];
for (let m = 0; m < live_sc_rooms.length; m++) {
let sc_keep_time_item = unsafeWindow.localStorage.getItem('live_' + live_sc_rooms[m] + '_sc_keep_time');
if (sc_keep_time_item === null || sc_keep_time_item === 'null' || sc_keep_time_item === 0 || sc_keep_time_item === '') {
continue;
} else if (sc_keep_time_item !== null && sc_keep_time_item !== 'null' && sc_keep_time_item !== 0 && sc_keep_time_item !== '' && ((sc_now_time - sc_keep_time_item) / (1000 * 60 * 60)) > sc_clear_time_hour) {
unsafeWindow.localStorage.removeItem('live_' + live_sc_rooms[m] + '_sc'); // 清除sc存储
unsafeWindow.localStorage.removeItem('live_' + live_sc_rooms[m] + '_sc_sid'); // 清除sc的sid存储
unsafeWindow.localStorage.removeItem('live_' + live_sc_rooms[m] + '_sc_keep_time'); //清除sc的keep time存储
} else {
live_sc_rooms_new.push(live_sc_rooms[m]);
}
}
// 更新live_sc_rooms
unsafeWindow.localStorage.setItem('live_sc_rooms', JSON.stringify(live_sc_rooms_new));
}
}
function check_blacklist_menu(room_id) {
let sc_room_black_list_json = unsafeWindow.localStorage.getItem('live_sc_room_blacklist');
if (sc_room_black_list_json === null || sc_room_black_list_json === 'null' || sc_room_black_list_json === '[]' || sc_room_black_list_json === '') {
// 显示加入黑名单
GM_registerMenuCommand('点击将当前直播房间加入黑名单', function() {
unsafeWindow.localStorage.setItem('live_sc_room_blacklist', JSON.stringify([room_id]));
sc_catch_log('直播房间id:' + room_id + ' 已加入黑名单!');
alert("当前直播房间已加入黑名单,刷新页面生效!");
unsafeWindow.location.reload();
});
return true;
} else {
let sc_room_black_list = JSON.parse(sc_room_black_list_json);
if (sc_room_black_list.includes(room_id)) {
// 显示移除黑名单
GM_registerMenuCommand('当前直播房间已加入黑名单,点击移出黑名单', function() {
sc_room_black_list = sc_room_black_list.filter(item => item !== room_id);
unsafeWindow.localStorage.setItem('live_sc_room_blacklist', JSON.stringify(sc_room_black_list));
sc_catch_log('直播房间id:' + room_id + ' 已移出黑名单!');
alert("当前直播房间已除出黑名单,刷新页面生效!");
unsafeWindow.location.reload();
});
return false;
} else {
// 显示加入黑名单
GM_registerMenuCommand('点击将当前直播房间加入黑名单', function() {
sc_room_black_list.push(room_id);
unsafeWindow.localStorage.setItem('live_sc_room_blacklist', JSON.stringify(sc_room_black_list));
sc_catch_log('直播房间id:' + room_id + ' 已加入黑名单!');
alert("当前直播房间已加入黑名单,刷新页面生效!");
unsafeWindow.location.reload();
});
return true;
}
}
}
function getTimestampConversion(timestamp) {
let timeStamp;
let timeStampLen = timestamp.toString().length;
if (timeStampLen === 10) {
timeStamp = timestamp * 1000
} else if (timeStampLen === 13) {
timeStamp = timestamp
} else {
timeStamp = timestamp
}
let date = new Date(timeStamp); // 时间戳为10位需*1000,时间戳为13位的话不需乘1000
let Y = (date.getFullYear() + '-');
let M = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1) + '-';
let D = (date.getDate() < 10 ? '0' + date.getDate() + ' ' : date.getDate() + ' ');
let h = (date.getHours() < 10 ? '0' + date.getHours() + ':' : date.getHours() + ':');
let m = (date.getMinutes() < 10 ? '0' + date.getMinutes() + ':' : date.getMinutes() + ':');
let s = (date.getSeconds() < 10 ? '0' + date.getSeconds() : date.getSeconds());
return Y + M + D + h + m + s;
}
function getTimestampDiff(timestamp) {
let timeStamp;
let timeStampLen = timestamp.toString().length;
if (timeStampLen === 10) {
timeStamp = timestamp * 1000
} else if (timeStampLen === 13) {
timeStamp = timestamp
} else {
timeStamp = timestamp
}
let nowTime = (new Date()).getTime();
let timeDiffValue = nowTime - timeStamp;;
let resultStr = '';
if (timeDiffValue < 0) {
return resultStr;
}
var dayDiff = timeDiffValue / (1000 * 60 * 60 * 24);
var hourDiff = timeDiffValue / (1000 * 60 * 60);
var minDiff = timeDiffValue / (1000 * 60);
if (dayDiff >= 1) {
resultStr = '' + parseInt(dayDiff) + '天前';
} else if (hourDiff >= 1) {
resultStr = '' + parseInt(hourDiff) + '小时前';
} else if (minDiff >= 1) {
resultStr = '' + parseInt(minDiff) + '分钟前';
} else {
resultStr = '刚刚';
}
return resultStr;
}
// 更新每条SC距离当前时间
function updateTimestampDiff() {
let sc_timestamp_item = $(document).find('.sc_start_timestamp');
sc_timestamp_item.each(function() {
let new_timestamp_diff = getTimestampDiff($(this).html());
$(this).prev().html(new_timestamp_diff);
});
}
function close_and_remove_sc_modal() {
// 关闭模态框
$(document).find('.sc_cp_mod').hide();
// 从 body 中移除模态框
$(document).find('.sc_cp_mod').remove();
}
function open_and_close_sc_modal(show_str, show_color, e, mode = 0) {
$(document).find('.sc_long_rectangle').css('cursor', 'grab');
let sc_copy_modal = document.createElement('div');
sc_copy_modal.className = 'sc_cp_mod';
sc_copy_modal.style.position = 'fixed';
sc_copy_modal.style.display = 'none';
sc_copy_modal.style.color = show_color;
sc_copy_modal.style.textAlign = 'center';
sc_copy_modal.style.backgroundColor = '#ffffff';
sc_copy_modal.style.border = 0;
sc_copy_modal.style.boxShadow = '0 0 3px rgba(0, 0, 0, 0.3)';
sc_copy_modal.innerHTML = show_str;
sc_copy_modal.style.zIndex = 3333;
if (mode === 0) {
sc_copy_modal.style.width = '30px';
sc_copy_modal.style.height = '30px';
sc_copy_modal.style.lineHeight = '30px';
sc_copy_modal.style.borderRadius = '50%';
sc_copy_modal.style.left = e.clientX + 10 + 'px';
sc_copy_modal.style.top = e.clientY - 10 + 'px';
} else {
sc_copy_modal.style.borderRadius = '10px';
sc_copy_modal.style.padding = '10px';
sc_copy_modal.style.left = e.target.getBoundingClientRect().left + 10 + 'px';
sc_copy_modal.style.top = e.target.getBoundingClientRect().top - 30 + 'px';
}
if (sc_isFullscreen) {
$(document).find('#live-player').append(sc_copy_modal);
} else {
document.body.appendChild(sc_copy_modal);
}
// 显示模态框
sc_copy_modal.style.display = 'block';
// 在一定时间后关闭并删除模态框
setTimeout(() => {
close_and_remove_sc_modal();
}, 1500);
}
function check_and_join_live_sc_room() {
if (!sc_keep_time_flag) {
sc_keep_time_flag = 1;
// 加入记录组
let live_sc_rooms_json = unsafeWindow.localStorage.getItem('live_sc_rooms');
if (live_sc_rooms_json === null || live_sc_rooms_json === 'null' || live_sc_rooms_json === '[]' || live_sc_rooms_json === '') {
unsafeWindow.localStorage.setItem('live_sc_rooms', JSON.stringify([room_id]));
} else {
let live_sc_rooms = JSON.parse(live_sc_rooms_json);
live_sc_rooms.push(room_id);
unsafeWindow.localStorage.setItem('live_sc_rooms', JSON.stringify(live_sc_rooms));
}
}
}
function sc_sleep(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
}
let sc_live_sidebar_try_find = 2; // 最多再尝试2次
function sc_live_sidebar_position_left_apply() {
let sc_live_sidebar = $(document).find('#sidebar-vm');
if (sc_live_sidebar.length) {
let sc_live_sidebar_cntr = sc_live_sidebar.find('.side-bar-cntr');
let sc_live_sidebar_popup_cntr = sc_live_sidebar.find('.side-bar-popup-cntr');
if (sc_live_sidebar_cntr.length) {
sc_live_sidebar_cntr.css('right', 'unset');
sc_live_sidebar_cntr.css('left', 0);
sc_live_sidebar_cntr.css('border-radius', '0 12px 12px 0');
}
if (sc_live_sidebar_popup_cntr.length) {
sc_live_sidebar_popup_cntr.css('left', sc_live_sidebar_popup_cntr.css('right'));
sc_live_sidebar_popup_cntr.css('right', 'unset');
let sc_live_sidebar_popup_cntr_arrow = sc_live_sidebar_popup_cntr.find('.arrow');
if (sc_live_sidebar_popup_cntr_arrow.length) {
sc_live_sidebar_popup_cntr_arrow.css('left', 'unset');
sc_live_sidebar_popup_cntr_arrow.css('right', '100%');
sc_live_sidebar_popup_cntr_arrow.css('border-color', 'transparent var(--bg1_float, "#FFFFFF") transparent transparent');
}
}
} else {
if (sc_live_sidebar_try_find) {
setTimeout(() => { sc_live_sidebar_position_left_apply() }, 2000);
sc_live_sidebar_try_find--;
}
}
}
function sc_live_sidebar_position_right_apply() {
let sc_live_sidebar = $(document).find('#sidebar-vm');
if (sc_live_sidebar.length) {
let sc_live_sidebar_cntr = sc_live_sidebar.find('.side-bar-cntr');
let sc_live_sidebar_popup_cntr = sc_live_sidebar.find('.side-bar-popup-cntr');
if (sc_live_sidebar_cntr.length) {
sc_live_sidebar_cntr.css('left', 'unset');
sc_live_sidebar_cntr.css('right', 0);
sc_live_sidebar_cntr.css('border-radius', '12px 0 0 12px');
}
if (sc_live_sidebar_popup_cntr.length) {
sc_live_sidebar_popup_cntr.css('right', sc_live_sidebar_popup_cntr.css('left'));
sc_live_sidebar_popup_cntr.css('left', 'unset');
let sc_live_sidebar_popup_cntr_arrow = sc_live_sidebar_popup_cntr.find('.arrow');
if (sc_live_sidebar_popup_cntr_arrow.length) {
sc_live_sidebar_popup_cntr_arrow.css('right', 'unset');
sc_live_sidebar_popup_cntr_arrow.css('left', '100%');
sc_live_sidebar_popup_cntr_arrow.css('border-color', 'transparent transparent transparent var(--bg1_float, "#FFFFFF")');
}
}
}
}
function sc_side_fold_in_one(target_oj) {
target_oj.css('border-radius', '8px');
target_oj.find('.sc_msg_body').hide();
target_oj.find('.sc_msg_head').css('border-radius', '6px');
target_oj.find('.sc_msg_head_left').hide();
target_oj.find('.sc_msg_head_right').hide();
}
function sc_side_fold_out_one(target_oj, mouse_enter_flag = false) {
target_oj.css('border-radius', '8px 8px 6px 6px');
let sc_item_fold_flag = target_oj.attr('data-fold');
if (sc_item_fold_flag === '0') {
target_oj.find('.sc_msg_body').show();
target_oj.find('.sc_msg_head').css('border-radius', '6px 6px 0px 0px');
if (mouse_enter_flag) {
target_oj.attr('data-height', target_oj.outerHeight())
}
}
target_oj.find('.sc_msg_head_left').show();
target_oj.find('.sc_msg_head_right').show();
}
function sc_side_fold_in_all() {
$(document).find('.sc_long_item').each(function() {
sc_side_fold_in_one($(this));
});
}
function sc_side_fold_out_all() {
$(document).find('.sc_long_item').each(function() {
sc_side_fold_out_one($(this));
});
}
function sc_trigger_item_side_fold_in(target_oj_class) {
let target_oj = $(document).find('.' + target_oj_class);
target_oj.css('position', '');
target_oj.css('top', '');
target_oj.css('z-index', '');
target_oj.css('width', '50px');
target_oj.css('height', '50px');
target_oj.css('left', '');
sc_side_fold_in_one(target_oj);
}
function sc_auto_trigger_side_fold_out_next() {
if (sc_panel_fold_mode === 1) {
sc_side_fold_custom_auto_run_flag = true;
let auto_target_oj = $(document).find('.' + sc_side_fold_custom_each_same_time_class);
if (auto_target_oj.length === 0) { sc_side_fold_custom_auto_run_flag = false; return; }
if (sc_side_fold_custom_stop_from_auto_flag) {
let auto_target_oj_next = auto_target_oj.prev();
if (sc_item_order_up_flag) {
auto_target_oj_next = auto_target_oj.next();
}
if (auto_target_oj_next.length) {
auto_target_oj = auto_target_oj_next;
sc_side_fold_custom_each_same_time_class = auto_target_oj.attr('class').split(' ').find((scClassName) => { return scClassName !== 'sc_long_item'; });
}
}
auto_target_oj.css('position', 'absolute');
auto_target_oj.css('top', '0px'); // 第一个SC的位置
auto_target_oj.css('translateY', '-100%');
auto_target_oj.css('opacity', 0);
auto_target_oj.css('z-index', '10');
auto_target_oj.css('width', (sc_rectangle_width - 22) + 'px'); // 22 约为总padding
auto_target_oj.css('height', '');
if ((auto_target_oj.offset().left - (unsafeWindow.innerWidth / 2)) > 0) {
if (sc_panel_list_height === 0) {
auto_target_oj.css('left', -(sc_rectangle_width - 22 - 72 + 10 + 60)); // 22 约为总padding, 72为侧折后的宽,10为一个padding
} else {
auto_target_oj.css('left', -(sc_rectangle_width - 22 - 72 + 10)); // 22 约为总padding, 72为侧折后的宽,10为一个padding
}
} else {
if (sc_panel_list_height === 0) {
auto_target_oj.css('left', 70);
}
}
sc_side_fold_out_one(auto_target_oj, true);
auto_target_oj.hide();
auto_target_oj.animate({
'translateY': '0',
'opacity' : 1
}, {
duration: 1000,
easing: 'linear'
});
auto_target_oj.show();
sc_side_fold_custom_each_same_time_timeout_id = setTimeout(function() {
if (sc_side_fold_custom_each_same_time_class && sc_panel_fold_mode === 1) {
// 下一个SC
let prev_target_oj = auto_target_oj.prev();
if (sc_item_order_up_flag) {
prev_target_oj = auto_target_oj.next();
}
if (prev_target_oj.length > 0) {
sc_trigger_item_side_fold_in(sc_side_fold_custom_each_same_time_class);
sc_side_fold_custom_each_same_time_class = prev_target_oj.attr('class').split(' ').find((scClassName) => { return scClassName !== 'sc_long_item'; });
sc_side_fold_custom_stop_from_auto_flag = false;
sc_sleep(1500).then(() => { sc_auto_trigger_side_fold_out_next() });
} else {
if (sc_side_fold_custom_config === 2) {
sc_trigger_item_side_fold_in(sc_side_fold_custom_each_same_time_class);
}
sc_side_fold_custom_auto_run_flag = false;
sc_side_fold_custom_stop_from_auto_flag = true;
}
}
}, sc_side_fold_custom_time * 1000);
}
}
function sc_auto_trigger_side_fold_out_start(target_oj_class) {
if (sc_side_fold_custom_each_same_time_class === '') {
// 如果是刚刚开始
sc_side_fold_custom_each_same_time_class = target_oj_class;
sc_auto_trigger_side_fold_out_next();
} else {
// 如果已经暂停了
if (!sc_side_fold_custom_auto_run_flag) {
sc_auto_trigger_side_fold_out_next();
}
}
}
function sc_trigger_item_side_fold_out(target_oj_class) {
let target_oj = $(document).find('.' + target_oj_class);
if (sc_side_fold_custom_each_same_time_flag) {
sc_auto_trigger_side_fold_out_start(target_oj_class);
} else {
target_oj.css('position', 'absolute');
target_oj.css('top', '0px'); // 第一个SC的位置
target_oj.css('z-index', '10');
target_oj.css('width', (sc_rectangle_width - 22) + 'px'); // 22 约为总padding
target_oj.css('height', '');
if ((target_oj.offset().left - (unsafeWindow.innerWidth / 2)) > 0) {
target_oj.css('left', -(sc_rectangle_width - 22 - 72 + 10)); // 22 约为总padding, 72为侧折后的宽,10为一个padding
}
sc_side_fold_out_one(target_oj, true);
}
}
function sc_custom_config_start_class_by_fetch(sc_catch_new_arr) {
if (Array.isArray(sc_catch_new_arr)) {
let first_catch_sc = sc_catch_new_arr[0];
if (first_catch_sc) {
sc_side_fold_custom_each_same_time_class = 'sc_' + first_catch_sc["uid"] + '_' + first_catch_sc["start_time"];
}
}
}
function sc_custom_config_start_class_by_store(sc_store_arr) {
if (Array.isArray(sc_store_arr)) {
let first_store_sc = sc_store_arr.at(-1);
if (first_store_sc) {
sc_side_fold_custom_each_same_time_class = 'sc_' + first_store_sc["uid"] + '_' + first_store_sc["start_time"];
}
}
}
function sc_custom_config_apply(new_sc_side_fold_custom_first_class) {
if (sc_panel_side_fold_flag) {
if (sc_side_fold_custom_config === 1) {
// 第一个SC保持展开
if (sc_side_fold_custom_first_class && sc_panel_fold_mode === 1 && sc_side_fold_custom_first_class !== new_sc_side_fold_custom_first_class && !sc_side_fold_custom_auto_run_flag) {
sc_trigger_item_side_fold_in(sc_side_fold_custom_first_class);
}
if (new_sc_side_fold_custom_first_class && sc_panel_fold_mode === 1) {
sc_trigger_item_side_fold_out(new_sc_side_fold_custom_first_class);
}
} else if (sc_side_fold_custom_config === 2) {
// 第一个SC不保持展开
if (sc_side_fold_custom_first_class && sc_panel_fold_mode === 1 && sc_side_fold_custom_first_class !== new_sc_side_fold_custom_first_class && !sc_side_fold_custom_auto_run_flag) {
sc_trigger_item_side_fold_in(sc_side_fold_custom_first_class);
}
if (sc_side_fold_custom_first_timeout_id) {
clearTimeout(sc_side_fold_custom_first_timeout_id);
}
if (new_sc_side_fold_custom_first_class && sc_panel_fold_mode === 1) {
sc_trigger_item_side_fold_out(new_sc_side_fold_custom_first_class);
}
if (!sc_side_fold_custom_each_same_time_flag) {
sc_side_fold_custom_first_timeout_id = setTimeout(function() {
if (new_sc_side_fold_custom_first_class && sc_panel_fold_mode === 1) {
sc_trigger_item_side_fold_in(new_sc_side_fold_custom_first_class);
}
}, sc_side_fold_custom_time * 1000);
}
}
}
}
// 检查全记的状态
function check_all_memory_status() {
// 只有当前的记忆模式是全记时才检查
if (sc_memory === 3) {
let sc_btn_memory = $(document).find('.sc_button_memory');
let sc_memory_all_rooms_mode = unsafeWindow.localStorage.getItem('live_sc_memory_all_rooms_mode');
if (sc_memory_all_rooms_mode !== null && sc_memory_all_rooms_mode !== 'null' && sc_memory_all_rooms_mode !== '') {
if (parseInt(sc_memory_all_rooms_mode, 10) !== 3) {
sc_memory = 0;
sc_btn_memory.text('没记');
}
} else {
sc_memory = 0;
sc_btn_memory.text('没记');
}
}
}
// 记忆存储
function update_sc_memory_config(config_item_name, config_item_val, type = 'self') {
let sc_memory_config_key = sc_self_memory_config_key
if (type === 'all') {
sc_memory_config_key = 'live_sc_all_memory_config';
}
let sc_memory_config = {};
let sc_memory_config_json = unsafeWindow.localStorage.getItem(sc_memory_config_key);
if (sc_memory_config_json !== null && sc_memory_config_json !== 'null' && sc_memory_config_json !== '[]' && sc_memory_config_json !== '{}' && sc_memory_config_json !== '') {
sc_memory_config = JSON.parse(sc_memory_config_json);
}
if (config_item_name === 'sc_panel_drag' && Array.isArray(config_item_val)) {
sc_memory_config['sc_panel_drag_left'] = config_item_val[0] ?? -1;
sc_memory_config['sc_panel_drag_top'] = config_item_val[1] ?? -1;
} else {
sc_memory_config[config_item_name] = config_item_val;
}
unsafeWindow.localStorage.setItem(sc_memory_config_key, JSON.stringify(sc_memory_config));
}
function sc_switch_store() {
if (sc_memory === 1) {
// 题记
unsafeWindow.localStorage.setItem('live_sc_switch_record', sc_switch);
} else if (sc_memory === 2) {
// 个记
update_sc_memory_config('sc_switch', sc_switch, 'self');
} else if (sc_memory === 3) {
// 全记
update_sc_memory_config('sc_switch', sc_switch, 'all');
}
}
function sc_fold_mode_store() {
if (sc_memory === 2) {
// 个记
update_sc_memory_config('sc_panel_fold_mode', sc_panel_fold_mode, 'self');
} else if (sc_memory === 3) {
// 全记
update_sc_memory_config('sc_panel_fold_mode', sc_panel_fold_mode, 'all');
}
}
function sc_panel_side_fold_flag_store() {
if (sc_memory === 2) {
// 个记
update_sc_memory_config('sc_panel_side_fold_flag', sc_panel_side_fold_flag, 'self');
} else if (sc_memory === 3) {
// 全记
update_sc_memory_config('sc_panel_side_fold_flag', sc_panel_side_fold_flag, 'all');
}
}
function sc_side_fold_simple_store() {
if (sc_memory === 2) {
// 个记
update_sc_memory_config('sc_panel_side_fold_simple', sc_panel_side_fold_simple, 'self');
} else if (sc_memory === 3) {
// 全记
update_sc_memory_config('sc_panel_side_fold_simple', sc_panel_side_fold_simple, 'all');
}
}
function sc_panel_drag_store(sc_panel_drag_left_val, sc_panel_drag_top_val) {
if (sc_panel_drag_left_val <= 0) {
sc_panel_drag_left_val = 0;
}
if (sc_panel_drag_top_val <= 0) {
sc_panel_drag_top_val = 0;
}
if (sc_panel_drag_left_val >= unsafeWindow.innerWidth) {
if (sc_panel_fold_mode === 1) {
sc_panel_drag_left_val = unsafeWindow.innerWidth - 72;
} else {
sc_panel_drag_left_val = unsafeWindow.innerWidth - sc_rectangle_width;
}
}
if (sc_panel_drag_top_val >= unsafeWindow.innerHeight) {
sc_panel_drag_top_val = unsafeWindow.innerHeight - sc_panel_list_height;
}
if (sc_memory === 2) {
// 个记
update_sc_memory_config('sc_panel_drag', [sc_panel_drag_left_val, sc_panel_drag_top_val], 'self');
} else if (sc_memory === 3) {
// 全记
update_sc_memory_config('sc_panel_drag', [sc_panel_drag_left_val, sc_panel_drag_top_val], 'all');
}
}
function sc_func_btn_mode_store() {
if (sc_memory === 2) {
// 个记
update_sc_memory_config('sc_func_btn_mode', sc_func_btn_mode, 'self');
} else if (sc_memory === 3) {
// 全记
update_sc_memory_config('sc_func_btn_mode', sc_func_btn_mode, 'all');
}
}
function sc_data_show_bottom_store() {
if (sc_memory === 2) {
// 个记
update_sc_memory_config('data_show_bottom_flag', data_show_bottom_flag, 'self');
} else if (sc_memory === 3) {
// 全记
update_sc_memory_config('data_show_bottom_flag', data_show_bottom_flag, 'all');
}
}
function sc_panel_allow_drag_store() {
if (sc_memory === 2) {
// 个记
update_sc_memory_config('sc_panel_allow_drag_flag', sc_panel_allow_drag_flag, 'self');
} else if (sc_memory === 3) {
// 全记
update_sc_memory_config('sc_panel_allow_drag_flag', sc_panel_allow_drag_flag, 'all');
}
}
function sc_start_time_show_store() {
if (sc_memory === 2) {
// 个记
update_sc_memory_config('sc_start_time_show_flag', sc_start_time_show_flag, 'self');
} else if (sc_memory === 3) {
// 全记
update_sc_memory_config('sc_start_time_show_flag', sc_start_time_show_flag, 'all');
}
}
function sc_side_fold_custom_config_store() {
if (sc_memory === 2) {
// 个记
update_sc_memory_config('sc_side_fold_custom_config', sc_side_fold_custom_config, 'self');
update_sc_memory_config('sc_side_fold_custom_time', sc_side_fold_custom_time, 'self');
update_sc_memory_config('sc_side_fold_custom_each_same_time_flag', sc_side_fold_custom_each_same_time_flag, 'self');
} else if (sc_memory === 3) {
// 全记
update_sc_memory_config('sc_side_fold_custom_config', sc_side_fold_custom_config, 'all');
update_sc_memory_config('sc_side_fold_custom_time', sc_side_fold_custom_time, 'all');
update_sc_memory_config('sc_side_fold_custom_each_same_time_flag', sc_side_fold_custom_each_same_time_flag, 'all');
}
}
function sc_welt_hide_circle_half_store() {
if (sc_memory === 2) {
// 个记
update_sc_memory_config('sc_welt_hide_circle_half_flag', sc_welt_hide_circle_half_flag, 'self');
} else if (sc_memory === 3) {
// 全记
update_sc_memory_config('sc_welt_hide_circle_half_flag', sc_welt_hide_circle_half_flag, 'all');
}
}
function sc_rectangle_width_store() {
if (sc_memory === 2) {
// 个记
update_sc_memory_config('sc_rectangle_width', sc_rectangle_width, 'self');
} else if (sc_memory === 3) {
// 全记
update_sc_memory_config('sc_rectangle_width', sc_rectangle_width, 'all');
}
}
function sc_panel_list_height_store() {
if (sc_memory === 2) {
// 个记
update_sc_memory_config('sc_panel_list_height', sc_panel_list_height, 'self');
} else if (sc_memory === 3) {
// 全记
update_sc_memory_config('sc_panel_list_height', sc_panel_list_height, 'all');
}
}
function sc_live_sidebar_left_flag_store() {
if (sc_memory === 2) {
// 个记
update_sc_memory_config('sc_live_sidebar_left_flag', sc_live_sidebar_left_flag, 'self');
} else if (sc_memory === 3) {
// 全记
update_sc_memory_config('sc_live_sidebar_left_flag', sc_live_sidebar_left_flag, 'all');
}
}
function sc_item_order_up_flag_store() {
if (sc_memory === 2) {
// 个记
update_sc_memory_config('sc_item_order_up_flag', sc_item_order_up_flag, 'self');
} else if (sc_memory === 3) {
// 全记
update_sc_memory_config('sc_item_order_up_flag', sc_item_order_up_flag, 'all');
}
}
function update_sc_switch_rooms(type = 'add') {
let sc_switch_memory_rooms = [];
let sc_switch_memory_rooms_json = unsafeWindow.localStorage.getItem('live_sc_switch_memory_rooms');
if (sc_switch_memory_rooms_json !== null && sc_switch_memory_rooms_json !== 'null' && sc_switch_memory_rooms_json !== '[]' && sc_switch_memory_rooms_json !== '') {
sc_switch_memory_rooms = JSON.parse(sc_switch_memory_rooms_json);
}
if (type === 'add') {
sc_switch_memory_rooms.push(room_id);
} else {
sc_switch_memory_rooms = sc_switch_memory_rooms.filter(item => item !== room_id);
}
unsafeWindow.localStorage.setItem('live_sc_switch_memory_rooms', JSON.stringify(sc_switch_memory_rooms));
}
// 显示所有按钮
function sc_menu() {
$(document).find('.sc_button_item').show();
$(document).find('.sc_button_menu').hide();
}
function sc_scroll_list_to_bottom() {
let the_sc_list = $(document).find('.sc_long_list');
the_sc_list.each(function() {
$(this).scrollTop($(this)[0].scrollHeight);
});
}
// 折叠/展开单个消息
function sc_toggle_msg_body() {
let this_sc_item_class_arr = $(this).attr('class').split(' ');
let this_sc_item_dynamic_className = this_sc_item_class_arr.find((scClassName) => { return scClassName !== 'sc_long_item'; });
let this_sc_msg_body = $('.' + this_sc_item_dynamic_className).find('.sc_msg_body');
let this_sc_item_bg_color = $('.' + this_sc_item_dynamic_className).css('background-color');
if (this_sc_msg_body.is(":visible")) {
this_sc_msg_body.slideUp(200);
$('.' + this_sc_item_dynamic_className).css('border-radius', '8px');
this_sc_msg_body.prev().css('border-radius', '6px');
$('.' + this_sc_item_dynamic_className).find('.sc_value_font').css('color', this_sc_item_bg_color);
$('.' + this_sc_item_dynamic_className).attr('data-fold', '1');
} else {
$('.' + this_sc_item_dynamic_className).css('border-radius', '8px 8px 6px 6px');
this_sc_msg_body.prev().css('border-radius', '6px 6px 0px 0px');
this_sc_msg_body.slideDown(200);
$('.' + this_sc_item_dynamic_className).find('.sc_value_font').css('color', '');
$('.' + this_sc_item_dynamic_className).attr('data-fold', '0');
}
}
// 按钮模式选择
function sc_btn_mode_apply() {
if (sc_panel_side_fold_flag) {
if (sc_func_btn_mode === 0) {
// 侧折模式下显示所有的按钮
sc_menu();
} else if (sc_func_btn_mode === 1) {
// 侧折模式下隐藏所有的按钮
$(document).find('.sc_button_item').hide();
} else if (sc_func_btn_mode === 2) {
// 侧折模式下按钮的极简模式
$(document).find('.sc_button_item').hide();
$(document).find('.sc_button_menu').show();
$(document).find('.sc_button_min').show();
} else if (sc_func_btn_mode === 3) {
// 侧折模式下只显示折叠按钮
$(document).find('.sc_button_item').hide();
$(document).find('.sc_button_min').show();
} else if (sc_func_btn_mode === 4) {
// 侧折模式下只显示菜单按钮
$(document).find('.sc_button_item').hide();
$(document).find('.sc_button_menu').show();
}
sc_rectangle_is_slide_down = false;
}
}
// 贴边半隐藏
function sc_circle_welt_hide_half(sc_circle_left = -10, sc_circle_top = -10) {
let sc_circle_oj = $(document).find('.sc_long_circle');
let rect_circle = sc_circle_oj[0].getBoundingClientRect();
if (rect_circle.width === 0 && rect_circle.height === 0) {
return;
}
if (sc_circle_left === -10 && sc_circle_top === -10) {
sc_circle_left = sc_circle_oj.position().left;
sc_circle_top = sc_circle_oj.position().top;
}
if (sc_circle_left <= 1) {
sc_circle_oj.removeClass('sc_circle_x_left_show_animate');
sc_circle_oj.addClass('sc_circle_x_left_hide_animate');
} else if (sc_circle_top <= 1) {
sc_circle_oj.removeClass('sc_circle_y_top_show_animate');
sc_circle_oj.addClass('sc_circle_y_top_hide_animate');
} else if (sc_circle_left >= unsafeWindow.innerWidth - 39) {
sc_circle_oj.removeClass('sc_circle_x_right_show_animate');
sc_circle_oj.addClass('sc_circle_x_right_hide_animate');
} else if (sc_circle_top >= unsafeWindow.innerHeight - 39) {
sc_circle_oj.removeClass('sc_circle_y_bottom_show_animate');
sc_circle_oj.addClass('sc_circle_y_bottom_hide_animate');
}
}
// 侧折显示板
function sc_sidefold(flag = true) {
$(document).find('.sc_long_rectangle').css('width', '72px');
$(document).find('.sc_long_list').css('padding-left', '11px');
$(document).find('.sc_long_item').css('width', '50px');
$(document).find('.sc_long_item').css('height', '50px');
let sc_btn_item = $(document).find('.sc_button_item');
sc_btn_item.css('margin-top', '6px');
sc_btn_item.css('margin-bottom', '0px');
sc_btn_item.css('margin-right', '0px');
let sc_btn_sidefold = $(document).find('.sc_button_sidefold');
sc_btn_sidefold.addClass('sc_button_foldback');
sc_btn_sidefold.removeClass('sc_button_sidefold');
sc_btn_sidefold.text('展开');
let sc_data_show = $(document).find('.sc_data_show');
sc_data_show.css('margin-bottom', '15px');
sc_data_show.css('height', '70px');
$(document).find('.sc_label_data_br').show();
let sc_label_high_energy_left = $(document).find('.sc_high_energy_num_left');
let sc_label_high_energy_right = $(document).find('.sc_high_energy_num_right');
let sc_label_captain_left = $(document).find('.sc_captain_num_left');
let sc_label_captain_right = $(document).find('.sc_captain_num_right');
let sc_label_num_br3 = $(document).find('.sc_label_num_br3');
let clone_sc_label_captain_right = sc_label_captain_right.last().clone(true);
let clone_sc_label_num_br3 = sc_label_num_br3.last().clone(true);
clone_sc_label_captain_right.css('float', 'none');
sc_data_show.append(clone_sc_label_num_br3);
sc_data_show.append(clone_sc_label_captain_right);
sc_label_captain_right.remove();
sc_label_num_br3.remove();
sc_label_high_energy_left.css('float', 'right');
sc_label_high_energy_right.css('float', 'none');
sc_label_captain_left.css('margin-top', '10px');
let sc_long_rectangle = $(document).find('.sc_long_rectangle');
let sc_long_buttons = $(document).find('.sc_long_buttons');
let clone_sc_data_show = sc_data_show.last().clone(true);
let clone_sc_long_buttons = sc_long_buttons.last().clone(true);
clone_sc_long_buttons.hide();
if (sc_panel_side_fold_simple) {
clone_sc_data_show.hide();
} else {
sc_long_rectangle.css('border-bottom', '');
}
sc_long_rectangle.append(clone_sc_data_show);
sc_long_rectangle.append(clone_sc_long_buttons);
sc_data_show.remove();
sc_long_buttons.remove();
sc_side_fold_in_all();
sc_panel_side_fold_flag = true;
if (flag) {
if (unsafeWindow.innerHeight - sc_long_rectangle.position().top < sc_panel_list_height + 280) {
sc_long_rectangle.each(function() {
$(this).css('top', unsafeWindow.innerHeight - sc_panel_list_height - 280);
});
}
sc_panel_fold_mode = 1;
sc_fold_mode_store();
sc_panel_side_fold_flag_store();
if (sc_item_order_up_flag) {
sc_scroll_list_to_bottom();
}
}
sc_btn_mode_apply();
sc_side_fold_custom_auto_run_flag = false;
sc_custom_config_apply(sc_side_fold_custom_first_class);
}
// 侧折后恢复展开显示板
function sc_foldback() {
if (sc_side_fold_custom_first_class && sc_panel_fold_mode === 1) { sc_trigger_item_side_fold_in(sc_side_fold_custom_first_class); }
if (sc_side_fold_custom_first_timeout_id) { clearTimeout(sc_side_fold_custom_first_timeout_id); }
if (sc_side_fold_custom_each_same_time_class && sc_panel_fold_mode === 1) { sc_trigger_item_side_fold_in(sc_side_fold_custom_each_same_time_class); }
if (sc_side_fold_custom_each_same_time_timeout_id) { clearTimeout(sc_side_fold_custom_each_same_time_timeout_id); }
$(document).find('.sc_long_rectangle').css('width', sc_rectangle_width + 'px');
$(document).find('.sc_long_list').css('padding-left', '10px');
$(document).find('.sc_long_item').css('width', '');
$(document).find('.sc_long_item').css('height', '');
let sc_btn_item = $(document).find('.sc_button_item');
sc_btn_item.css('margin-top', '15px');
sc_btn_item.css('margin-bottom', '15px');
sc_btn_item.css('margin-right', '7px');
$(document).find('.sc_button_min').css('margin-right', '0px');
let sc_btn_foldback = $(document).find('.sc_button_foldback');
sc_btn_foldback.addClass('sc_button_sidefold');
sc_btn_foldback.removeClass('sc_button_foldback');
sc_btn_foldback.text('侧折');
let sc_data_show = $(document).find('.sc_data_show');
sc_data_show.css('margin-bottom', '20px');
sc_data_show.css('height', '20px');
$(document).find('.sc_label_data_br').hide();
let sc_label_high_energy_left = $(document).find('.sc_high_energy_num_left');
let sc_label_high_energy_right = $(document).find('.sc_high_energy_num_right');
let sc_label_captain_left = $(document).find('.sc_captain_num_left');
let sc_label_captain_right = $(document).find('.sc_captain_num_right');
let sc_label_num_br3 = $(document).find('.sc_label_num_br3');
let clone_sc_label_captain_left = sc_label_captain_left.last().clone(true);
let clone_sc_label_num_br3 = sc_label_num_br3.last().clone(true);
clone_sc_label_captain_left.css('margin-top', '0px');
sc_data_show.append(clone_sc_label_num_br3);
sc_data_show.append(clone_sc_label_captain_left);
sc_label_captain_left.remove();
sc_label_num_br3.remove();
sc_label_high_energy_left.css('float', 'left');
sc_label_high_energy_right.css('float', 'left');
sc_label_captain_right.css('float', 'right');
let sc_long_rectangle = $(document).find('.sc_long_rectangle');
let sc_long_buttons = $(document).find('.sc_long_buttons');
let clone_sc_data_show = sc_data_show.last().clone(true);
let clone_sc_long_buttons = sc_long_buttons.last().clone(true);
sc_long_rectangle.css('border-bottom', '10px solid transparent');
sc_long_rectangle.prepend(clone_sc_data_show);
sc_long_rectangle.prepend(clone_sc_long_buttons);
sc_data_show.remove();
sc_long_buttons.remove();
if (unsafeWindow.innerWidth - sc_long_rectangle.position().left < sc_rectangle_width) {
sc_long_rectangle.each(function() {
$(this).css('left', unsafeWindow.innerWidth - sc_rectangle_width - 15);
});
}
sc_side_fold_out_all();
sc_panel_fold_mode = 2;
sc_panel_side_fold_flag = false;
sc_fold_mode_store();
sc_panel_side_fold_flag_store();
sc_menu();
clone_sc_data_show.slideUp(500);
clone_sc_long_buttons.slideUp(500);
if (sc_item_order_up_flag) {
sc_scroll_list_to_bottom();
}
}
// 折叠显示板
function sc_minimize() {
if (sc_side_fold_custom_first_class && sc_panel_fold_mode === 1) { sc_trigger_item_side_fold_in(sc_side_fold_custom_first_class); }
if (sc_side_fold_custom_first_timeout_id) { clearTimeout(sc_side_fold_custom_first_timeout_id); }
if (sc_side_fold_custom_each_same_time_class && sc_panel_fold_mode === 1) { sc_trigger_item_side_fold_in(sc_side_fold_custom_each_same_time_class); }
if (sc_side_fold_custom_each_same_time_timeout_id) { clearTimeout(sc_side_fold_custom_each_same_time_timeout_id); }
$(document).find('.sc_long_circle').show();
$(document).find('.sc_long_rectangle').hide();
$(document).find('.sc_long_buttons').hide(); // 优化回弹问题
sc_panel_fold_mode = 0;
sc_fold_mode_store();
if (sc_welt_hide_circle_half_flag) { sc_circle_welt_hide_half(); }
}
// 切换主题
function sc_switch_css(flag = false) {
if (flag) {
sc_switch++;
// 记录主题
sc_switch_store();
}
let sc_rectangle = $(document).find('.sc_long_rectangle');
let sc_item = $(document).find('.sc_long_item');
let sc_list = $(document).find('.sc_long_list');
let sc_data_show = $(document).find('.sc_data_show');
let sc_button_item = $(document).find('.sc_button_item');
if (sc_switch === 0) {
// 白色
sc_rectangle.css('background-color', 'rgba(255,255,255,1)');
sc_rectangle.css('box-shadow', '2px 2px 5px black');
sc_item.css('box-shadow', 'rgba(0, 0, 0, 0.5) 2px 2px 2px');
if (sc_panel_side_fold_flag) {
sc_list.css('padding', '0px 14px 0px 11px');
} else {
sc_list.css('padding', '0px 13px 0px 10px');
}
sc_data_show.css('color', '');
sc_button_item.css('background', 'linear-gradient(90deg, #A7C9D3, #eeeeee, #5c95d7, #A7C9D3)');
sc_button_item.css('background-size', '350%');
sc_button_item.css('border', 0);
$(document).find('#sc_scrollbar_style').text(`
.sc_long_list::-webkit-scrollbar {
width: 6px;
}
.sc_long_list:hover::-webkit-scrollbar-thumb {
background: rgba(204,204,204,0.5);
border-radius: 6px;
}
.sc_long_list::-webkit-scrollbar-thumb {
background: rgba(204,204,204,0);
}
`);
} else if(sc_switch === 1) {
// 透明
sc_rectangle.css('background-color', 'rgba(255,255,255,0)');
sc_rectangle.css('box-shadow', '');
sc_item.css('box-shadow', '');
if (sc_panel_side_fold_flag){
sc_list.css('padding', '0px 12px 0px 11px');
} else {
sc_list.css('padding', '0px 11px 0px 10px');
}
sc_data_show.css('color', '#ffffff');
sc_button_item.css('background', 'rgba(255,255,255,0)');
sc_button_item.css('border', '1px solid #ffffff');
$(document).find('#sc_scrollbar_style').text(`
.sc_long_list::-webkit-scrollbar {
width: 6px;
}
.sc_long_list:hover::-webkit-scrollbar-thumb {
background: rgba(255,255,255,0.1);
border-radius: 6px;
}
.sc_long_list::-webkit-scrollbar-thumb {
background: rgba(255,255,255,0);
}
`);
} else if(sc_switch === 2) {
// 半透明(白0.1)
sc_rectangle.css('background-color', 'rgba(255,255,255,0.1)');
sc_item.css('box-shadow', 'rgba(0, 0, 0, 0.5) 2px 2px 2px');
if (sc_panel_side_fold_flag) {
sc_list.css('padding', '0px 14px 0px 11px');
} else {
sc_list.css('padding', '0px 13px 0px 10px');
}
sc_data_show.css('color', '#ffffff');
sc_button_item.css('background', 'linear-gradient(90deg, #A7C9D3, #eeeeee, #5c95d7, #A7C9D3)');
sc_button_item.css('background-size', '350%');
sc_button_item.css('border', 0);
$(document).find('#sc_scrollbar_style').text(`
.sc_long_list::-webkit-scrollbar {
width: 6px;
}
.sc_long_list:hover::-webkit-scrollbar-thumb {
background: rgba(204,204,204,0.2);
border-radius: 6px;
}
.sc_long_list::-webkit-scrollbar-thumb {
background: rgba(204,204,204,0);
}
`);
} else if(sc_switch === 3) {
// 半透明(白0.5)
sc_rectangle.css('background-color', 'rgba(255,255,255,0.5)');
sc_item.css('box-shadow', 'rgba(0, 0, 0, 0.5) 2px 2px 2px');
if (sc_panel_side_fold_flag) {
sc_list.css('padding', '0px 14px 0px 11px');
} else {
sc_list.css('padding', '0px 13px 0px 10px');
}
sc_data_show.css('color', '');
sc_button_item.css('background', 'linear-gradient(90deg, #A7C9D3, #eeeeee, #5c95d7, #A7C9D3)');
sc_button_item.css('background-size', '350%');
sc_button_item.css('border', 0);
$(document).find('#sc_scrollbar_style').text(`
.sc_long_list::-webkit-scrollbar {
width: 6px;
}
.sc_long_list:hover::-webkit-scrollbar-thumb {
background: rgba(204,204,204,0.5);
border-radius: 6px;
}
.sc_long_list::-webkit-scrollbar-thumb {
background: rgba(204,204,204,0);
}
`);
} else if(sc_switch === 4) {
// 半透明(黑色0.1)
sc_rectangle.css('background-color', 'rgba(0,0,0,0.1)');
sc_rectangle.css('box-shadow', '');
sc_item.css('box-shadow', '');
if (sc_panel_side_fold_flag) {
sc_list.css('padding', '0px 12px 0px 11px');
} else {
sc_list.css('padding', '0px 11px 0px 10px');
}
sc_data_show.css('color', '#ffffff');
sc_button_item.css('background', 'rgba(255,255,255,0)');
sc_button_item.css('border', '1px solid #ffffff');
$(document).find('#sc_scrollbar_style').text(`
.sc_long_list::-webkit-scrollbar {
width: 6px;
}
.sc_long_list:hover::-webkit-scrollbar-thumb {
background: rgba(255,255,255,0.2);
border-radius: 6px;
}
.sc_long_list::-webkit-scrollbar-thumb {
background: rgba(255,255,255,0);
}
`);
} else if(sc_switch === 5) {
// 半透明(黑色0.5)
sc_rectangle.css('background-color', 'rgba(0,0,0,0.5)');
sc_rectangle.css('box-shadow', '');
sc_item.css('box-shadow', '');
if (sc_panel_side_fold_flag) {
sc_list.css('padding', '0px 12px 0px 11px');
} else {
sc_list.css('padding', '0px 12px 0px 10px');
}
sc_data_show.css('color', '#ffffff');
sc_button_item.css('background', 'rgba(255,255,255,0)');
sc_button_item.css('border', '1px solid #ffffff');
$(document).find('#sc_scrollbar_style').text(`
.sc_long_list::-webkit-scrollbar {
width: 6px;
}
.sc_long_list:hover::-webkit-scrollbar-thumb {
background: rgba(255,255,255,0.2);
border-radius: 6px;
}
.sc_long_list::-webkit-scrollbar-thumb {
background: rgba(255,255,255,0);
}
`);
} else {
// 白色
sc_switch = 0;
sc_rectangle.css('background-color', 'rgba(255,255,255,1)');
sc_item.css('box-shadow', 'rgba(0, 0, 0, 0.5) 2px 2px 2px');
if (sc_panel_side_fold_flag) {
sc_list.css('padding', '0px 14px 0px 11px');
} else {
sc_list.css('padding', '0px 13px 0px 10px');
}
sc_data_show.css('color', '');
sc_button_item.css('background', 'linear-gradient(90deg, #A7C9D3, #eeeeee, #5c95d7, #A7C9D3)');
sc_button_item.css('background-size', '350%');
sc_button_item.css('border', 0);
$(document).find('#sc_scrollbar_style').text(`
.sc_long_list::-webkit-scrollbar {
width: 6px;
}
.sc_long_list:hover::-webkit-scrollbar-thumb {
background: rgba(204,204,204,0.5);
border-radius: 6px;
}
.sc_long_list::-webkit-scrollbar-thumb {
background: rgba(204,204,204,0);
}
`);
}
}
// 记忆模式
function sc_memory_modify() {
let sc_btn_memory = $(document).find('.sc_button_memory');
if (sc_memory === 1) {
// 从[题记]切换到其他模式时,在题记房间中剔除当前房间
update_sc_switch_rooms('del');
} else if (sc_memory === 2) {
// 从[个记]切换到其他模式时,删除当前的个记配置
unsafeWindow.localStorage.removeItem(sc_self_memory_config_key);
} else if (sc_memory=== 3) {
// 从[全记]切换到其他模式时,删除全记配置
unsafeWindow.localStorage.removeItem('live_sc_memory_all_rooms_mode');
unsafeWindow.localStorage.removeItem('live_sc_all_memory_config');
}
sc_memory++;
if (sc_memory === 0) {
sc_btn_memory.text('没记');
} else if(sc_memory === 1) {
sc_btn_memory.text('题记');
update_sc_switch_rooms('add');
// 切换到题记的配置
let sc_switch_record = unsafeWindow.localStorage.getItem('live_sc_switch_record');
if (sc_switch_record !== null && sc_switch_record !== 'null' && sc_switch_record !== '') {
sc_switch = parseInt(sc_switch_record, 10);
sc_switch_css();
}
} else if(sc_memory === 2) {
sc_btn_memory.text('个记');
// 保存个记的配置
sc_switch_store();
sc_fold_mode_store();
sc_panel_side_fold_flag_store();
sc_side_fold_simple_store();
const rect_circle = $(document).find('.sc_long_circle')[0].getBoundingClientRect();
if (rect_circle.width === 0 && rect_circle.height === 0) {
const rect_rectangle = $(document).find('.sc_long_rectangle')[0].getBoundingClientRect();
sc_panel_drag_store(rect_rectangle.left, rect_rectangle.top);
} else {
sc_panel_drag_store(rect_circle.left, rect_circle.top);
}
} else if(sc_memory=== 3) {
sc_btn_memory.text('全记');
unsafeWindow.localStorage.setItem('live_sc_memory_all_rooms_mode', sc_memory);
// 保存全记的配置
sc_switch_store();
sc_fold_mode_store();
sc_panel_side_fold_flag_store();
sc_side_fold_simple_store();
const rect_circle = $(document).find('.sc_long_circle')[0].getBoundingClientRect();
if (rect_circle.width === 0 && rect_circle.height === 0) {
const rect_rectangle = $(document).find('.sc_long_rectangle')[0].getBoundingClientRect();
sc_panel_drag_store(rect_rectangle.left, rect_rectangle.top);
} else {
sc_panel_drag_store(rect_circle.left, rect_circle.top);
}
} else {
sc_memory = 0;
sc_btn_memory.text('没记');
}
}
function sc_memory_show() {
let sc_circles = $(document).find('.sc_long_circle');
let sc_rectangles = $(document).find('.sc_long_rectangle');
if (sc_panel_fold_mode) {
sc_circles.each(function() {
if (sc_panel_drag_left >= 0) {
$(this).css('left', sc_panel_drag_left + 'px');
}
if (sc_panel_drag_top >= 0) {
$(this).css('top', sc_panel_drag_top + 'px');
}
$(this).hide();
});
sc_rectangles.each(function() {
if (sc_panel_drag_left >= 0) {
$(this).css('left', sc_panel_drag_left + 'px');
}
if (sc_panel_drag_top >= 0) {
$(this).css('top', sc_panel_drag_top + 'px');
}
if (sc_panel_fold_mode === 1 && !sc_panel_side_fold_simple) {
$(document).find('.sc_data_show').show();
}
$(this).slideDown(500);
});
if (sc_panel_fold_mode === 1) { sc_sidefold(false); sc_btn_mode_apply(); }
} else {
if (sc_panel_side_fold_flag) { sc_sidefold(false); sc_btn_mode_apply(); }
sc_circles.each(function() {
if (sc_panel_drag_left >= 0) {
$(this).css('left', sc_panel_drag_left + 'px');
}
if (sc_panel_drag_top >= 0) {
$(this).css('top', sc_panel_drag_top + 'px');
}
});
if (sc_welt_hide_circle_half_flag) { sc_circle_welt_hide_half(sc_panel_drag_left, sc_panel_drag_top); }
}
if (sc_live_sidebar_left_flag) { setTimeout(() => { sc_live_sidebar_position_left_apply() }, 1000); }
}
// 导出
function sc_export() {
let sc_localstorage_json_export = unsafeWindow.localStorage.getItem(sc_localstorage_key);
if (sc_localstorage_json_export === null || sc_localstorage_json_export === 'null' || sc_localstorage_json_export === '[]' || sc_localstorage_json_export === '') {
return;
} else {
let sc_localstorage_export = JSON.parse(sc_localstorage_json_export);
let sc_export_str = '';
for (let j = 0; j < sc_localstorage_export.length; j++) {
let sc_export_timestamp = '[' + getTimestampConversion(sc_localstorage_export[j]["start_time"]) + ']';
let sc_export_uname = '[ ' + sc_localstorage_export[j]["user_info"]["uname"] + ' ]';
let sc_export_uid = '[ uid: ' + sc_localstorage_export[j]["uid"] + ' ]';
let sc_export_guard_level = sc_localstorage_export[j]["user_info"]["guard_level"];
let sc_export_guard = '';
if (sc_export_guard_level === 1) {
sc_export_guard = '[总督]'
} else if (sc_export_guard_level === 2) {
sc_export_guard = '[提督]';
} else if (sc_export_guard_level === 3) {
sc_export_guard = '[舰长]';
} else {
sc_export_guard = '[普通]';
}
let sc_export_price = '[ ¥' + sc_localstorage_export[j]["price"] + ' ]';
let sc_export_message = '[ ' + sc_localstorage_export[j]["message"] + ' ]';
sc_export_str += sc_export_timestamp + sc_export_guard + sc_export_uid + sc_export_uname + sc_export_price + ' : ' + sc_export_message + '\n\n';
}
// 创建一个Blob对象,将字符串放入其中
const sc_export_blob = new Blob([sc_export_str], { type: 'text/plain' });
// 创建一个下载链接
const sc_export_downloadLink = document.createElement('a');
sc_export_downloadLink.href = URL.createObjectURL(sc_export_blob);
// 设置文件名
sc_export_downloadLink.download = 'B站SC记录_' + sc_live_room_title + '_' + getTimestampConversion((new Date()).getTime()) + '.txt';
// 将链接添加到页面中,模拟点击下载
document.body.appendChild(sc_export_downloadLink);
sc_export_downloadLink.click();
// 移除链接
document.body.removeChild(sc_export_downloadLink);
}
}
function sc_startDragging(e) {
if (!sc_panel_allow_drag_flag) {
return;
}
e = e || unsafeWindow.event;
let sc_drag_target_classname = e.target.className;
if (sc_panel_fold_mode === 1 && sc_drag_target_classname !== 'sc_long_list' && sc_drag_target_classname !== 'sc_data_show' && sc_drag_target_classname !== 'sc_long_buttons' && !sc_drag_target_classname.includes('sc_button_item')) {
// 侧折模式下,禁止用SC拖拽
return;
}
if (e.button === 0) {
sc_isDragging = true;
sc_isClickAllowed = true;
const rect_circle = $(document).find('.sc_long_circle')[0].getBoundingClientRect();
if (rect_circle.width === 0 && rect_circle.height === 0) {
const rect_rectangle = $(document).find('.sc_long_rectangle')[0].getBoundingClientRect();
sc_offsetX = e.clientX - rect_rectangle.left;
sc_offsetY = e.clientY - rect_rectangle.top;
} else {
sc_offsetX = e.clientX - rect_circle.left;
sc_offsetY = e.clientY - rect_circle.top;
}
sc_drag_start = (new Date()).getTime();
}
}
function sc_stopDragging() {
if (!sc_panel_allow_drag_flag) {
return;
}
if (!sc_isClickAllowed) {
const rect_circle = $(document).find('.sc_long_circle')[0].getBoundingClientRect();
if (rect_circle.width === 0 && rect_circle.height === 0) {
const rect_rectangle = $(document).find('.sc_long_rectangle')[0].getBoundingClientRect();
sc_panel_drag_store(rect_rectangle.left, rect_rectangle.top);
if (sc_welt_hide_circle_half_flag) { sc_circle_welt_hide_half(rect_rectangle.left, rect_rectangle.top); }
} else {
sc_panel_drag_store(rect_circle.left, rect_circle.top);
if (sc_welt_hide_circle_half_flag) { sc_circle_welt_hide_half(rect_circle.left, rect_circle.top); }
}
}
sc_isDragging = false;
}
function sc_drag(e) {
if (!sc_panel_allow_drag_flag) {
return;
}
e = e || unsafeWindow.event;
if (sc_isDragging && ((new Date()).getTime() - sc_drag_start) > 30) {
let sc_elements = $(document).find('.sc_drag_div');
sc_elements.each(function() {
const rect = this.getBoundingClientRect();
const maxX = unsafeWindow.innerWidth - rect.width;
const maxY = unsafeWindow.innerHeight - rect.height;
let x = Math.min(maxX, Math.max(0, e.clientX - sc_offsetX)) + 0.5; // 这个0.5交给浏览器吧,至少chrome上是完美的
let y = Math.min(maxY, Math.max(0, e.clientY - sc_offsetY));
this.style.left = x + 'px';
this.style.top = y + 'px';
});
sc_isClickAllowed = false;
if (e.clientY < 0 || e.clientX < 0 || e.clientY >= unsafeWindow.innerHeight || e.clientX >= unsafeWindow.innerWidth - 5) {
// 页面外时触发 mouseup 事件的逻辑
sc_isDragging = false;
sc_stopDragging();
}
}
}
function sc_after_click_func_btn_apply(e, animate_flag = false) {
let click_page_x = e.clientX;
let click_page_y = e.clientY;
let sc_rectangle_model = document.getElementsByClassName('sc_long_rectangle');
let sc_rect_left = $(sc_rectangle_model).position().left;
let sc_rect_top = $(sc_rectangle_model).position().top;
let sc_data_model = document.getElementsByClassName('sc_data_show');
let sc_btn_model = document.getElementsByClassName('sc_long_buttons');
if (sc_panel_side_fold_flag) {
if (click_page_x < sc_rect_left || click_page_x - sc_rect_left > 72
|| click_page_y < sc_rect_top
|| (click_page_y > sc_rect_top && click_page_y - sc_rect_top > $(sc_rectangle_model).outerHeight())) {
if (animate_flag && sc_panel_side_fold_simple) {
$(sc_data_model).slideUp(500);
}
$(sc_btn_model).slideUp(500, () => {
sc_rectangle_is_slide_up = false;
});
if (!sc_panel_side_fold_simple) {
$(sc_rectangle_model).css('border-bottom', '');
}
}
if (!sc_panel_side_fold_simple && sc_func_btn_mode === 1) {
$(sc_rectangle_model).css('border-bottom', '');
}
} else if (sc_panel_fold_mode == 2) {
if (click_page_x < sc_rect_left || click_page_x - sc_rect_left > sc_rectangle_width
|| click_page_y < sc_rect_top
|| (click_page_y > sc_rect_top && click_page_y - sc_rect_top > $(sc_rectangle_model).outerHeight())) {
$(sc_data_model).slideUp(500);
$(sc_btn_model).slideUp(500, () => {
sc_rectangle_is_slide_up = false;
});
}
}
}
function update_sc_item(sc_data, realtime = true) {
// 追加SC 显示
let sc_background_bottom_color = sc_data["background_bottom_color"];
let sc_background_image = sc_data["background_image"];
let sc_background_color = sc_data["background_color"];
let sc_uid = sc_data["uid"];
let sc_user_info_face = sc_data["user_info"]["face"];
let sc_user_info_face_frame = sc_data["user_info"]["face_frame"];
let sc_user_info_uname = sc_data["user_info"]["uname"];
let sc_price = sc_data["price"];
let sc_message = sc_data["message"];
let sc_start_timestamp = sc_data["start_time"];
let sc_medal_flag = false;
let sc_medal_color = '';
let sc_medal_name = '';
let sc_medal_level = 0;
if (sc_data["medal_info"] && sc_data["medal_info"]["anchor_roomid"]) {
sc_medal_flag = true;
sc_medal_color = sc_data["medal_info"]["medal_color"];
sc_medal_name = sc_data["medal_info"]["medal_name"];
sc_medal_level = sc_data["medal_info"]["medal_level"];
}
let sc_background_image_html = '';
if (sc_background_image !== '') {
sc_background_image_html = 'background-image: url('+ sc_background_image +');';
}
let sc_font_color = '#666666';
let sc_font_color_data = sc_data["user_info"]["name_color"] ?? '#666666';
let sc_start_time = getTimestampConversion(sc_start_timestamp);
let sc_diff_time = getTimestampDiff(sc_start_timestamp);
let sc_user_info_face_img = '';
let sc_user_info_face_frame_img = '';
if (sc_user_info_face_frame !== '') {
sc_user_info_face_img = '
';
sc_user_info_face_frame_img = '
';
}
let box_shadow_css = '';
if (sc_switch === 0 || sc_switch === 2 || sc_switch === 3) {
box_shadow_css = 'box-shadow: rgba(0, 0, 0, 0.5) 2px 2px 2px;';
}
let sc_start_time_display = '';
if (!sc_start_time_show_flag) {
sc_start_time_display = 'display: none;';
}
let metal_and_start_time_html = '
侧折模式下留言显示设置:
侧折模式下留言显示设置:
醒目留言(记录板)宽度自定义设置:
醒目留言(记录板)宽度自定义设置:
记录板高度自定义设置:
记录板高度自定义设置:
设置记录板留言的排列顺序:
设置记录板留言的排列顺序: