Revival TweetDeck Integration

This commit is contained in:
cutls 2021-04-09 16:35:40 +09:00
parent 816665f7d3
commit b42105fabe
16 changed files with 134 additions and 25 deletions

View File

@ -537,9 +537,10 @@ function multiSelector(parseC) {
}
last = last + ''
var sel
const webview = localStorage.getItem('webview_setting') === 'true'
if (obj.length < 1) {
$('#src-acct-sel').html('<option value="tootsearch">Tootsearch</option>')
$('#add-acct-sel').html('<option value="noauth">' + lang.lang_login_noauth + '</option>')
$('#add-acct-sel').html('<option value="noauth">' + lang.lang_login_noauth + `</option>${webview ? `<option value="webview">TweetDeck</option>` : ''}`)
} else {
Object.keys(obj).forEach(function (key) {
var acct = obj[key]
@ -610,7 +611,7 @@ function multiSelector(parseC) {
$('#add-acct-sel').append(
'<option value="noauth">' +
lang.lang_login_noauth +
'</option><!--option value="webview">Twitter</option-->'
`</option>${webview ? `<option value="webview">TweetDeck</option>` : ''}`
)
$('#dir-acct-sel').append('<option value="noauth">' + lang.lang_login_noauth + '</option>')
}

View File

@ -198,6 +198,8 @@ onmessage = function (e) {
type: 'info',
title: e.data[1]
})
} else if (e.data[0] == 'twitterLoginComplete') {
location.reload()
}
}
/* PWA */

View File

@ -3,7 +3,7 @@ window.onload = function () {
initPostbox()
connection()
initPlugin(plugins)
if(localStorage.getItem('control-center-np')) $('#ccnp').removeClass('hide')
if (localStorage.getItem('control-center-np')) $('#ccnp').removeClass('hide')
}
$.strip_tags = function (str, allowed) {
if (!str) {
@ -290,3 +290,23 @@ function statusModel(now) {
poll: null
}
}
function webviewFinder() {
const webview = document.querySelector('webview')
webview.addEventListener('did-navigate', (e) => {
const url = webview.getURL()
if (url.match('https://mobile.twitter.com/login')) {
postMessage(['twitterLogin', null], '*')
} else if (url.match('https://mobile.twitter.com/logout')) {
postMessage(['twitterLogin', true], '*')
}
})
}
function initWebviewEvent() {
if (document.querySelector('webview')) { webviewFinder() } else {
const timerWV = setInterval(function () {
document.querySelector('webview')
? (webviewFinder(), clearInterval(timerWV))
: console.log('まだロード中')
}, 500)
}
}

View File

@ -54,6 +54,8 @@ onmessage = function(e) {
ipc.send('theme-json-request', e.data[1])
} else if (e.data[0] == 'ha') {
ipc.send('ha', e.data[1])
} else if (e.data[0] == 'webviewSetting') {
ipc.send('webview', e.data[1])
} else if (e.data[0] == 'frameSet') {
ipc.send('frameSet', e.data[1])
} else if (e.data[0] == 'ua') {
@ -77,6 +79,8 @@ onmessage = function(e) {
ipc.send('copy', e.data[1])
} else if (e.data[0] == 'log') {
ipc.send('log', e.data[1])
} else if (e.data[0] == 'twitterLogin') {
ipc.send('twitterLogin', e.data[1])
}
}
//version.js
@ -227,9 +231,6 @@ ipc.on('asReadEnd', function(event, arg) {
ipc.on('accessibility', function(event, arg) {
postMessage(['accessibility', 'true'], '*')
})
var webviewDom = document.getElementById('webview')
if (webviewDom) {
webviewDom.addEventListener('new-window', function(e) {
shell.openExternal(e.url)
})
}
ipc.on('twitterLoginComplete', function(event, arg) {
postMessage(['twitterLoginComplete', ''], '*')
})

View File

@ -185,6 +185,7 @@ function parseColumn(target, dontclose) {
}
var html = webviewParse('https://tweetdeck.twitter.com', key, insert, icnsert, css)
$('#timeline-container').append(html)
initWebviewEvent()
} else if (acct.type == 'tootsearch') {
if (!acct.left_fold) {
basekey = key

View File

@ -13,16 +13,18 @@ var envView = new Vue({
for (var j = 0; j < ls.length; j++) {
M.toast({ html: 'Complete', displayLength: 3000 })
var id = ls[j].id
var val = $('#' + id).val()
localStorage.setItem(ls[j].storage, val)
}
if (ls == 'ha') {
if (ls[0].id == 'ha') {
hardwareAcceleration(val)
}
if (ls == 'ua_setting') {
if (ls[0].id == 'webview') {
postMessage(['webviewSetting', val], '*')
}
if (ls[0].id == 'ua_setting') {
useragent(val)
}
if (ls == 'frame') {
if (ls[0].id == 'frame') {
frameSet(val)
}
return true
@ -302,7 +304,7 @@ function oksload() {
function changeLang() {
const lang = $('#langsel-sel').val()
console.log(lang)
if(lang) postMessage(['lang', lang], '*')
if (lang) postMessage(['lang', lang], '*')
}
function exportSettings() {
var exp = exportSettingsCore()
@ -787,7 +789,7 @@ function completePlugin(comp) {
var pgns = localStorage.getItem('plugins')
var args = JSON.parse(pgns ? pgns : '[]')
var id = $('#plugin').attr('data-id')
var inputPlugin = editor.getValue()
var meta = getMeta(inputPlugin)
if (!meta.data) {
@ -821,7 +823,7 @@ function completePlugin(comp) {
}
var ss = args
localStorage.setItem('plugins', JSON.stringify(ss))
if(comp) return false
if (comp) return false
$('#plugin').attr('data-id', 'add_new')
editor.setValue('', -1)
pluginLoad()

View File

@ -123,6 +123,7 @@ function createWindow() {
var info_path = join(app.getPath('userData'), 'window-size.json')
var max_info_path = join(app.getPath('userData'), 'max-window-size.json')
var ha_path = join(app.getPath('userData'), 'hardwareAcceleration')
var wv_path = join(app.getPath('userData'), 'webview')
var ua_path = join(app.getPath('userData'), 'useragent')
try {
fs.readFileSync(ha_path, 'utf8')
@ -131,6 +132,8 @@ function createWindow() {
} catch {
if (!packaged) console.log('enabled: Hardware Acceleration')
}
let webviewEnabled = false
if(fs.existsSync(wv_path, 'utf8')) webviewEnabled = true
var window_size
try {
window_size = JSON.parse(fs.readFileSync(info_path, 'utf8'))
@ -156,7 +159,7 @@ function createWindow() {
var bit = process.arch
var arg = {
webPreferences: {
webviewTag: true,
webviewTag: webviewEnabled,
nodeIntegration: false,
contextIsolation: true,
spellcheck: false,

View File

@ -9,6 +9,7 @@ function system(mainWindow, dir, lang, dirname) {
const clipboard = electron.clipboard
var tmp_img = join(app.getPath('userData'), 'tmp.png')
var ha_path = join(app.getPath('userData'), 'hardwareAcceleration')
var wv_path = join(app.getPath('userData'), 'webview')
var ua_path = join(app.getPath('userData'), 'useragent')
var lang_path = join(app.getPath('userData'), 'language')
var log_dir_path = join(app.getPath('userData'), 'logs')
@ -100,7 +101,16 @@ function system(mainWindow, dir, lang, dirname) {
if (arg == 'true') {
fs.writeFileSync(ha_path, arg)
} else {
fs.unlink(ha_path, function (err) {})
fs.unlink(ha_path, function (err) { })
}
app.relaunch()
app.exit()
})
ipc.on('webview', function (e, arg) {
if (arg == 'true') {
fs.writeFileSync(wv_path, arg)
} else {
fs.unlink(wv_path, function (err) { })
}
app.relaunch()
app.exit()
@ -108,7 +118,7 @@ function system(mainWindow, dir, lang, dirname) {
//ユーザーエージェント
ipc.on('ua', function (e, arg) {
if (arg == '') {
fs.unlink(ua_path, function (err) {})
fs.unlink(ua_path, function (err) { })
} else {
fs.writeFileSync(ua_path, arg)
}
@ -299,5 +309,28 @@ function system(mainWindow, dir, lang, dirname) {
})
}
})
ipc.on('twitterLogin', (e, args) => {
const window = new BrowserWindow({
webPreferences: {
webviewTag: false,
nodeIntegration: false,
contextIsolation: true,
preload: join(dirname, 'js', 'platform', 'preload.js'),
},
width: 414,
height: 736,
})
const login = `https://mobile.twitter.com/login?hide_message=true&redirect_after_login=https%3A%2F%2Ftweetdeck.twitter.com%2F%3Fvia_twitter_login%3Dtrue`
const logout = `https://mobile.twitter.com/logout?redirect_after_logout=https%3A%2F%2Ftweetdeck.twitter.com%2F`
window.loadURL(args ? logout : login)
window.webContents.on('did-navigate', () => {
const url = window.webContents.getURL()
if (url.match("https://tweetdeck.twitter.com")) {
window.close()
e.sender.webContents.send('twitterLoginComplete', '')
}
})
})
}
exports.system = system

View File

@ -18,6 +18,8 @@
"export": "Export",
"hardwareAcceleration": "Disable hardware acceleration",
"hardwareAccelerationWarn": "Auto restarted",
"webview": "Webview Integration",
"webviewWarn": "To use TweetDeck Integration, please turn on. You should understand it may lessen security level.",
"theme": "Themes",
"popup": "Popup notification",
"popupwarn": "Hide to set \"0\"",

View File

@ -17,6 +17,8 @@
"export": "エクスポート",
"hardwareAcceleration": "ハードウェアアクセラレーションの無効化",
"hardwareAccelerationWarn": "表示(特に設定画面)があかんときは「はい」を選んでな。再起動入るで。",
"webview": "Webviewの使用",
"webviewWarn": "TweetDeck使いたかったら「はい」にしてほしいんやけど、セキュリティ的には結構あかんやつやから、使わんのやったらちゃんと「いいえ」にしといてな。再起動入るで。",
"theme": "テーマの設定",
"popup": "新規通知のポップアップお知らせの表示秒数",
"popupwarn": "0にしたら出さへん",

View File

@ -18,6 +18,8 @@
"export": "エクスポート",
"hardwareAcceleration": "ハードウェアアクセラレーションの無効化",
"hardwareAccelerationWarn": "表示(特に設定画面)が乱れる場合に「はい」を選択してください。自動で再起動します。",
"webview": "Webviewの使用",
"webviewWarn": "TweetDeckを埋め込むために必要です。セキュリティに影響するため、使用しないときは「いいえ」を選択してください。自動で再起動します。",
"theme": "テーマの設定",
"popup": "新規通知のポップアップお知らせの表示秒数",
"popupwarn": "0に設定すると表示されません",

View File

@ -29,7 +29,7 @@ function main(ver, basefile, pwa, store) {
fs.writeFileSync(basefile + 'git', gitHash)
console.log('Constructing view files ' + ver)
const langs = ['ja', 'ja-KS', 'en', 'bg', 'cs', 'de',
'es-AR', 'it-IT', 'zh-CN', 'zh-TW', 'fr-FR', 'no-NO', 'pt-BR', 'ru-RU', 'es-ES','pl-PL', 'ps']
'es-AR', 'it-IT', 'zh-CN', 'fr-FR', 'zh-TW', 'no-NO', 'pt-BR', 'ru-RU', 'es-ES','pl-PL', 'ps']
const langsh = [
'日本語',
'日本語(関西)',

View File

@ -154,6 +154,26 @@ var envConstruction = [
desc: '@@useragentWarn@@'
}
},
{
id: 'webview',
storage: 'webview_setting',
checkbox: true,
setValue: false,
text: {
head: '@@webview@@',
desc: '@@webviewWarn@@',
checkbox: [
{
text: '@@yes@@',
value: 'true'
},
{
text: '@@no@@',
value: 'false'
}
]
}
},
{
id: 'srcUrl',
storage: 'srcUrl',

View File

@ -26,7 +26,7 @@
<body class="">
<script>
var ver = '22.1.1 (Koume)'
var gitHash = '6e75ea7f374fe887b8956bcb9bdac5524133b865'
var gitHash = '816665f7d335ffd75978b96126cf43ecf456e983'
//betaを入れるとバージョンチェックしない
//var ver="beta";
var acct_id = 0

View File

@ -55,7 +55,7 @@
<h5>Języki</h5>
<div style="display: flex;">
<div style="width: 22rem;" id="langsel">
<select id="langsel-sel"><option value="ja">日本語</option><option value="ja-KS">日本語(関西)</option><option value="en">English</option><option value="bg">български</option><option value="cs">Česky</option><option value="de">Deutsch</option><option value="es-AR">Español, argentina</option><option value="it-IT">italiano</option><option value="zh-CN">简体中文</option><option value="zh-TW">français</option><option value="fr-FR">繁體中文(β)</option><option value="no-NO">norsk(β)</option><option value="pt-BR">Português, brasileiro(β)</option><option value="ru-RU">русский(β)</option><option value="es-ES">Español(β)</option><option value="pl-PL">Polskie(β)</option><option value="ps">Crowdin translate system(beta)</option></select>
<select id="langsel-sel"><option value="ja">日本語</option><option value="ja-KS">日本語(関西)</option><option value="en">English</option><option value="bg">български</option><option value="cs">Česky</option><option value="de">Deutsch</option><option value="es-AR">Español, argentina</option><option value="it-IT">italiano</option><option value="zh-CN">简体中文</option><option value="fr-FR">français</option><option value="zh-TW">繁體中文(β)</option><option value="no-NO">norsk(β)</option><option value="pt-BR">Português, brasileiro(β)</option><option value="ru-RU">русский(β)</option><option value="es-ES">Español(β)</option><option value="pl-PL">Polskie(β)</option><option value="ps">Crowdin translate system(beta)</option></select>
</div>
<button class="btn waves-effect" onclick="changeLang()">Zmień</button>
</div>
@ -78,7 +78,7 @@
<template v-for="(check, j) in item.text.checkbox">
<label>
<input class="with-gap" v-on:click="complete(i,check.value)" v-model="item.setValue"
type="radio" v-bind:id="item.id+check.value" v-bind:value="check.value" />
type="radio" v-bind:id="item.id" v-bind:value="check.value" />
<span>{{check.text}}</span>
</label>
</template>
@ -609,7 +609,7 @@
style="width:100%; max-width:40rem;"><img src="../../img/desk_full.svg" class="left" width="25"
style="padding-top:5px;">Main author: Cutls@cutls.com</a>
<br>
TheDesk @ <a href="https://github.com/cutls/TheDesk/commits/6e75ea7f374fe887b8956bcb9bdac5524133b865">6e75ea7f374fe887b8956bcb9bdac5524133b865</a> - <a
TheDesk @ <a href="https://github.com/cutls/TheDesk/commits/816665f7d335ffd75978b96126cf43ecf456e983">816665f7d335ffd75978b96126cf43ecf456e983</a> - <a
onclick="checkupd(); return localStorage.removeItem('new-ver-skip'); location.href='index.html';"
class="pointer pwa">Sprawdź aktualizacje</a><br>
<br>
@ -619,7 +619,7 @@
<img src="https://status.cutls.com/badge-service?site=thedesk.top">
</a><br>
<h5>OSS License</h5>
<a href="https://app.fossa.com/projects/git%2Bgithub.com%2Fcutls%2FTheDesk/refs/branch/master/6e75ea7f374fe887b8956bcb9bdac5524133b865"
<a href="https://app.fossa.com/projects/git%2Bgithub.com%2Fcutls%2FTheDesk/refs/branch/master/816665f7d335ffd75978b96126cf43ecf456e983"
alt="FOSSA Status"><img
src="https://app.fossa.com/api/projects/git%2Bgithub.com%2Fcutls%2FTheDesk.svg?type=small" /></a>
<br>

View File

@ -154,6 +154,26 @@ var envConstruction = [
desc: 'Restart when changed'
}
},
{
id: 'webview',
storage: 'webview_setting',
checkbox: true,
setValue: false,
text: {
head: 'undefined',
desc: 'undefined',
checkbox: [
{
text: 'Tak',
value: 'true'
},
{
text: 'Nie',
value: 'false'
}
]
}
},
{
id: 'srcUrl',
storage: 'srcUrl',