From c24b6cb5ad49a90af6d1e227907045a4d99cce9c Mon Sep 17 00:00:00 2001 From: Le-Khoi Phong Date: Tue, 21 Feb 2017 19:47:41 +0800 Subject: [PATCH] add warning if not login --- app/styles/index.less | 9 +++++++++ app/utils/index.js | 22 +++++++++++++++++----- 2 files changed, 26 insertions(+), 5 deletions(-) diff --git a/app/styles/index.less b/app/styles/index.less index c560b4e..3807655 100644 --- a/app/styles/index.less +++ b/app/styles/index.less @@ -108,6 +108,15 @@ body { } } +#nologin-message { + padding: 5px; + width: 100%; + background: red; + color: white; + font-family: Tahoma; + font-size: 12px; +} + @import './thread-preview'; @import './side-menu'; @import './emotion-box'; diff --git a/app/utils/index.js b/app/utils/index.js index 2b75e8b..bf9e83c 100644 --- a/app/utils/index.js +++ b/app/utils/index.js @@ -15,12 +15,24 @@ export function getCurrentView() { export function getAuthenticationInformation() { const queryString = "*:contains('You last') > *:contains('Welcome') > a[href*='member.php?u']"; const username = $(queryString).eq(0).text(); - if (username === '') return { isLogin: false }; + if (username === '') { + if ($('#nologin-message').length === 0) { + $('.tborder:has(input[name="vb_login_username"])') + .before(`
Bạn cần phải đăng nhập để sử dụng đầy đủ các chức năng của plugin
`); + } + return { + isLogin: false, + }; + } new Function( $("script:not([src]):contains('SECURITYTOKEN')") - .text() - .replace('SECURITYTOKEN', 'SECURITYTOKEN=window.SECURITYTOKEN') - ).call(window); + .text() + .replace('SECURITYTOKEN', 'SECURITYTOKEN=window.SECURITYTOKEN') + ).call(window); const token = window.SECURITYTOKEN; - return { isLogin: true, token, username }; + return { + isLogin: true, + token, + username, + }; }