Skip to content

Commit

Permalink
v3.29.5
Browse files Browse the repository at this point in the history
  • Loading branch information
lekakid committed Nov 10, 2023
2 parents a3e91b8 + 013ff1b commit 494fdf2
Show file tree
Hide file tree
Showing 9 changed files with 34 additions and 29 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "arcarefresher",
"version": "3.29.4",
"version": "3.29.5",
"description": "",
"author": "LeKAKiD",
"license": "MIT",
Expand Down
12 changes: 7 additions & 5 deletions src/feature/NO_GROUP/VersionInfo/Feature.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ import { disableStorageSync } from 'core/storage';

import Info from './FeatureInfo';
import { $setCheckedVersion } from './slice';
import { compare } from './func';
import { parse, compare, join } from './func';

const MODE_UPGRADE = 1;
const MODE_DOWNGRADE = -1;
const MODE_DISABLE_STOAGE = -2;
const MODE_DISABLE_STORAGE = -2;

export default function VersionInfo() {
const dispatch = useDispatch();
Expand All @@ -34,7 +34,7 @@ export default function VersionInfo() {
boradcastChannel.onmessage = ({ data }) => {
if (data.msg === 'disable_storage') {
disableStorageSync();
setNoti({ open: true, mode: MODE_DISABLE_STOAGE });
setNoti({ open: true, mode: MODE_DISABLE_STORAGE });
}
};
}, [boradcastChannel, dispatch]);
Expand All @@ -58,7 +58,9 @@ export default function VersionInfo() {
const handleChangeLog = useCallback(() => {
const url =
'https://arca.live/b/namurefresher?category=%EC%97%85%EB%8D%B0%EC%9D%B4%ED%8A%B8&target=title&keyword=';
GM_openInTab(`${url}${GM_info.script.version}`);
const version = parse(GM_info.script.version);
version.patch = '*';
GM_openInTab(`${url}${join(version)}`);
setNoti({ open: false, mode: 0 });
dispatch($setCheckedVersion(GM_info.script.version));
}, [dispatch]);
Expand Down Expand Up @@ -103,7 +105,7 @@ export default function VersionInfo() {
);
break;
}
case MODE_DISABLE_STOAGE: {
case MODE_DISABLE_STORAGE: {
message = `이 탭의 스크립트 버전이 맞지 않습니다.
이 탭에서 변경한 설정, 메모 등이 저장되지 않습니다.`;
action = (
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
function parse(versionString) {
export function parse(versionString) {
const token = versionString.split('.');
return {
major: Number(token[0]),
Expand All @@ -7,14 +7,18 @@ function parse(versionString) {
};
}

export function join({ major, minor, patch }) {
return `${major}.${minor}.${patch}`;
}

/**
* 적용 중인 스크립트 버전과 마지막으로 확인한 버전을 비교합니다.
*
* @param {string} script 적용 중인 스크립트 버전 스트링
* @param {string} storage 마지막으로 확인한 버전 스트링
* @returns 값이 양수라면 업데이트 확인 필요, 음수라면 새로고침이 필요함
*/
function compare(script, storage) {
export function compare(script, storage) {
const scriptVersion = parse(script);
const storageVersion = parse(storage);

Expand All @@ -26,5 +30,3 @@ function compare(script, storage) {
}
return scriptVersion.patch - storageVersion.patch;
}

export default compare;
3 changes: 0 additions & 3 deletions src/feature/NO_GROUP/VersionInfo/func/index.jsx

This file was deleted.

5 changes: 2 additions & 3 deletions src/feature/Site/ShortKey/Feature.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,10 @@ export default function ShortKey() {

const eventListener = (e) => {
// 검색창 등 텍스트 입력칸
if (e.target.matches('input, textarea, [contenteditable]'))
return;
if (e.target.matches('input, textarea, [contenteditable]')) return;

// 조합키
if (e.ctrlKey || e.altKey || e.shiftKey) return;
if (e.ctrlKey || e.altKey || e.shiftKey || e.metaKey) return;

// 기타 기능
if (keyFilter.test(e.code)) return;
Expand Down
9 changes: 5 additions & 4 deletions src/feature/User/UserProfile/Feature.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,10 @@ function UserProfile() {

const show = () => {
[...document.querySelectorAll(USER_INFO)].forEach((e) => {
if (!getUserNick(e).includes('#')) return;
const fullNick = getUserNick(e);
if (!fullNick.includes('#')) return;

e.firstChild.textContent = e.firstChild.dataset.filter;
e.firstElementChild.textContent = fullNick;
});
};
show();
Expand All @@ -48,8 +49,8 @@ function UserProfile() {

return () => {
[...document.querySelectorAll(USER_INFO)].forEach((e) => {
const [hiddenID] = e.firstChild.textContent.split('#');
e.firstChild.textContent = hiddenID;
const [nick] = e.firstElementChild.textContent.split('#');
e.firstElementChild.textContent = nick;
});
removeEventListener(EVENT_BOARD_REFRESH, show);
removeEventListener(EVENT_COMMENT_REFRESH, show);
Expand Down
15 changes: 9 additions & 6 deletions src/func/user.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ export function getUserInfo(infoElement) {
}

export function getUserNick(infoElement) {
try {
const data = infoElement.querySelector('[data-filter]').dataset.filter;
const data = infoElement.querySelector('[data-filter]')?.dataset.filter;
if (data) {
const [, nick, id] = data
.match(/(.*)(#[0-9]{8})$|(.*), ([0-9]{1,3}\.[0-9]{1,3})$|(.*)/)
.filter((e) => e);
Expand All @@ -18,9 +18,11 @@ export function getUserNick(infoElement) {
}

return nick;
} catch {
return '';
}

const anchor = infoElement.querySelector('a');
const nick = anchor.title || anchor.textContent.replace('@', '');
return nick || '';
}

export function getUserID(infoElement) {
Expand All @@ -33,8 +35,9 @@ export function getUserID(infoElement) {
return id || nick;
}

const nick = infoElement.firstElementChild.textContent.replace('@', '');
return nick;
const anchor = infoElement.querySelector('a');
const nick = anchor.title || anchor.textContent.replace('@', '');
return nick || '';
}

export function getUserIP(infoElement) {
Expand Down
3 changes: 2 additions & 1 deletion src/hooks/Content.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { useLayoutEffect, useState } from 'react';

import {
ARTICLE_AUTHOR,
ARTICLE_LOADED,
ARTICLE_TITLE,
ARTICLE_URL,
Expand Down Expand Up @@ -154,7 +155,7 @@ export function useContent() {
titleElement.textContent.trim() ||
'제목 없음';
const author =
getUserNick(document.querySelector(`ARTICLE_AUTHOR`)) ||
getUserNick(document.querySelector(ARTICLE_AUTHOR)) ||
document.querySelector('.article-head .member-info').textContent.trim() ||
'익명';
const url =
Expand Down

0 comments on commit 494fdf2

Please sign in to comment.