introduce uuid yeah

This commit is contained in:
cutls 2021-06-19 19:16:08 +09:00
parent 679151e8ea
commit ab460d1401
11 changed files with 1897 additions and 1890 deletions

2
.gitignore vendored
View File

@ -26,7 +26,7 @@ app/git
*.code-workspace
releasenote.md
app/yarn-error.log
app/js/platform/aiscript.js
app/js/platform/native.js
app/view/es-ES
app/view/fr-FR
app/view/no-NO

View File

@ -16,6 +16,7 @@ $.strip_tags = function (str, allowed) {
return allowed.indexOf('<' + $1.toLowerCase() + '>') > -1 ? $0 : ''
})
}
function escapeHTML(str) {
if (!str) {
return ''
@ -36,6 +37,7 @@ function nl2br(str) {
str = str.replace(/(\n|\r)/g, '<br />')
return str
}
function br2nl(str) {
if (!str) {
return ''
@ -43,6 +45,7 @@ function br2nl(str) {
str = str.replace(/<br \/>/g, '\r\n')
return str
}
function formattime(date) {
var str = date.getFullYear() + '-'
if (date.getMonth() + 1 < 10) {
@ -68,6 +71,7 @@ function formattime(date) {
}
return escapeHTML(str)
}
function formattimeutc(date) {
var str = date.getUTCFullYear() + '-'
if (date.getUTCMonth() + 1 < 10) {
@ -94,30 +98,11 @@ function formattimeutc(date) {
return escapeHTML(str)
}
postMessage(['sendSinmpleIpc', 'custom-css-request'], '*')
function makeCID() {
let chars = "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".split("")
for (let i = 0, len = chars.length; i < len; i++) {
switch (chars[i]) {
case "x":
chars[i] = Math.floor(Math.random() * 16).toString(16)
break
case "y":
chars[i] = (Math.floor(Math.random() * 4) + 8).toString(16)
break
}
}
return chars.join("")
}
function randomStr(l) {
// 生成する文字列に含める文字セット
var c = 'abcdefghijklmnopqrstuvwxyz0123456789'
var cl = c.length
var r = ''
for (var i = 0; i < l; i++) {
r += c[Math.floor(Math.random() * cl)]
}
return r
return uuid()
}
function rgbToHex(color) {
// HEXに変換したものを代入する変数
var hex = ''
@ -200,6 +185,7 @@ function object_array_sort(data, key, order, fn) {
}
fn(data)
}
function setLog(txt1, txt2, txt3) {
//url,statuscode,responsetext
var text = new Date().toUTCString()
@ -207,6 +193,7 @@ function setLog(txt1, txt2, txt3) {
console.error(text)
postMessage(['log', text], '*')
}
function escapeCsv(str) {
if (!str) {
return str
@ -218,6 +205,7 @@ function escapeCsv(str) {
}
return result
}
function evalAttr(json, attr, lenCk) {
if (json[attr]) {
if (lenCk) {
@ -233,6 +221,7 @@ function evalAttr(json, attr, lenCk) {
return false
}
}
function statusModel(now) {
if (!now) {
var now = new Date().toString()
@ -290,6 +279,7 @@ function statusModel(now) {
poll: null
}
}
function webviewFinder() {
const webview = document.querySelector('webview')
webview.addEventListener('did-navigate', (e) => {
@ -301,12 +291,13 @@ function webviewFinder() {
}
})
}
function initWebviewEvent() {
if (document.querySelector('webview')) { webviewFinder() } else {
const timerWV = setInterval(function() {
document.querySelector('webview')
? (webviewFinder(), clearInterval(timerWV))
: console.log('まだロード中')
document.querySelector('webview') ?
(webviewFinder(), clearInterval(timerWV)) :
console.log('まだロード中')
}, 500)
}
}

View File

@ -651,16 +651,7 @@ function misskeyParse(obj, mix, acct_id, tlid, popup, mutefilter) {
if (toot.reactions) {
Object.keys(toot.reactions).forEach(function(keye) {
var thisReact = toot.reactions[keye]
if (keye == "like") { var defaultEmoji = true }
else if (keye == "love") { var defaultEmoji = true }
else if (keye == "laugh") { var defaultEmoji = true }
else if (keye == "hmm") { var defaultEmoji = true }
else if (keye == "surprise") { var defaultEmoji = true }
else if (keye == "congrats") { var defaultEmoji = true }
else if (keye == "angry") { var defaultEmoji = true }
else if (keye == "confused") { var defaultEmoji = true }
else if (keye == "star") { var defaultEmoji = true }
else {
if (keye == "like") { var defaultEmoji = true } else if (keye == "love") { var defaultEmoji = true } else if (keye == "laugh") { var defaultEmoji = true } else if (keye == "hmm") { var defaultEmoji = true } else if (keye == "surprise") { var defaultEmoji = true } else if (keye == "congrats") { var defaultEmoji = true } else if (keye == "angry") { var defaultEmoji = true } else if (keye == "confused") { var defaultEmoji = true } else if (keye == "star") { var defaultEmoji = true } else {
var obj = JSON.parse(localStorage.getItem("emoji_" + acct_id))
if (obj) {
var num = obj.length
@ -743,8 +734,24 @@ function misskeyParse(obj, mix, acct_id, tlid, popup, mutefilter) {
}
var fullhide = ""
} else {
var like = 0; var love = 0; var laugh = 0; var hmm = 0; var surprise = 0; var congrats = 0; var angry = 0; var confused = 0; var pudding = 0
var likehide = "hide"; var lovehide = "hide"; var laughhide = "hide"; var hmmhide = "hide"; var suphide = "hide"; var conghide = "hide"; var anghide = "hide"; var confhide = "hide"; var riphide = "hide"
var like = 0;
var love = 0;
var laugh = 0;
var hmm = 0;
var surprise = 0;
var congrats = 0;
var angry = 0;
var confused = 0;
var pudding = 0
var likehide = "hide";
var lovehide = "hide";
var laughhide = "hide";
var hmmhide = "hide";
var suphide = "hide";
var conghide = "hide";
var anghide = "hide";
var confhide = "hide";
var riphide = "hide"
var fullhide = "hide"
}
if (!addReact && likehide == "hide" && lovehide == "hide" && laughhide == "hide" && hmmhide == "hide" && suphide == "hide" && conghide == "hide" && anghide == "hide" && confhide == "hide" && riphide == "hide") {
@ -765,7 +772,7 @@ function misskeyParse(obj, mix, acct_id, tlid, popup, mutefilter) {
} else {
var actemojick = false
}
var rand = randomStr(8)
var rand = uuid()
templete = templete + '<div id="pub_' + toot.id + '" class="cvo ' +
boostback + ' ' + fav_app + ' ' + rt_app + ' ' + hasmedia + '" toot-id="' + id + '" unique-id="' + uniqueid + '" data-medias="' + media_ids + ' " unixtime="' + date(obj[
key].created_at, 'unix') + '" ' + if_notf + ' onmouseover="mov(\'' + toot.id + '\',\'' + tlid + '\',\'mv\', \'' + rand + '\')" onclick="mov(\'' + toot.id + '\',\'' + tlid + '\',\'cl\', \'' + rand + '\')" onmouseout="resetmv(\'mv\')" reacted="' + reacted + '">' +
@ -810,8 +817,8 @@ function misskeyParse(obj, mix, acct_id, tlid, popup, mutefilter) {
'</span></span><span class="' + riphide + ' reaction re-confused"><a onclick="reaction(\'confused\',\'' + toot.id + '\',' + acct_id +
',\'' + tlid + '\')" class="waves-effect waves-dark btn-flat pointer" style="padding:0;margin-left:3px;">' + twemoji.parse("😇") + '</a><span class="re-confusedct">' + rip +
'</span></span>' + addReact +
'<i class="material-icons pointer hide freeReact ' + freeReact + '" style="font-size:1.0rem; padding-left:5px;position: relative;top: 3px;" onclick="reactioncustom(\'' + acct_id + '\',\'' + id + '\')">add_box</i></div>'
+ poll + mentions + tags + '</div>' +
'<i class="material-icons pointer hide freeReact ' + freeReact + '" style="font-size:1.0rem; padding-left:5px;position: relative;top: 3px;" onclick="reactioncustom(\'' + acct_id + '\',\'' + id + '\')">add_box</i></div>' +
poll + mentions + tags + '</div>' +
'<div class="area-vis"></div>' +
'<div class="area-actions ' + mouseover + '">' +
'<div class="action">' + vis + '</div>' +
@ -835,8 +842,8 @@ function misskeyParse(obj, mix, acct_id, tlid, popup, mutefilter) {
')" class="waves-effect waves-dark btn-flat" style="padding:0" title="' + lang.lang_parse_del + '"><i class="fas fa-trash"></i></a></div>' +
'<div class="' + if_mine + ' action pin ' + disp["pin"] + ' ' + noauth + '"><a onclick="pin(\'' + toot.id + '\',' +
acct_id +
')" class="waves-effect waves-dark btn-flat" style="padding:0" title="' + lang.lang_parse_pin + '"><i class="fas fa-map-pin pin_' + toot.id + '"></i></a></div>'
+ '<div class="' + if_mine + ' action ' + disp["red"] + ' ' + noauth + '"><a onclick="redraft(\'' + toot.id + '\',' +
')" class="waves-effect waves-dark btn-flat" style="padding:0" title="' + lang.lang_parse_pin + '"><i class="fas fa-map-pin pin_' + toot.id + '"></i></a></div>' +
'<div class="' + if_mine + ' action ' + disp["red"] + ' ' + noauth + '"><a onclick="redraft(\'' + toot.id + '\',' +
acct_id +
')" class="waves-effect waves-dark btn-flat" style="padding:0" title="' + lang.lang_parse_redraft + '"><i class="material-icons">redo</i></a></div>' + trans +
'<span class="cbadge viabadge waves-effect ' + viashow + ' ' + mine_via + '" onclick="client(\'' + $.strip_tagstemp(via) + '\')" title="via ' + $.strip_tagstemp(via) + '">via ' +
@ -947,6 +954,7 @@ function misskeyUserparse(obj, auth, acct_id, tlid, popup) {
})
return templete
}
function goGoogle(id) {
var val = $("#srcbox_" + id).val()
var url = "https://google.com/search?q=" + val
@ -954,6 +962,7 @@ function goGoogle(id) {
}
var misskeyws = []
var misskeywsstate = []
function connectMisskey(acct_id, re) {
var domain = localStorage.getItem("domain_" + acct_id)
var at = localStorage.getItem("acct_" + acct_id + "_at")

View File

@ -3,8 +3,7 @@ function parse(obj, mix, acct_id, tlid, popup, mutefilter, type, onlyContent) {
var splitter = new GraphemeSplitter()
var templete = ''
if (obj[0]) {
if (tlid === 1) {
}
if (tlid === 1) {}
localStorage.setItem('lastunix_' + tlid, date(obj[0].created_at, 'unix'))
}
@ -343,8 +342,7 @@ function parse(obj, mix, acct_id, tlid, popup, mutefilter, type, onlyContent) {
if (native == 'yes') {
var os = localStorage.getItem('platform')
var options = {
body:
toot.account.display_name +
body: toot.account.display_name +
'(' +
toot.account.acct +
')' +
@ -996,7 +994,7 @@ function parse(obj, mix, acct_id, tlid, popup, mutefilter, type, onlyContent) {
menuct++
}
//このトゥート内のアクションを完了させるために、適当にIDを振る
var rand = randomStr(8)
var rand = uuid()
//プラグイン機構
var pluginBOT = plugins.buttonOnToot
var pluginHtml = ''
@ -1400,7 +1398,7 @@ function client(name) {
}
//Poll Parser
function pollParse(poll, acct_id, emojis) {
var rand = randomStr(8)
var rand = uuid()
var datetype = localStorage.getItem('datetype')
var anime = localStorage.getItem('animation')
if (anime == 'yes' || !anime) {

View File

@ -1,5 +1,7 @@
const { AiScript, parse, values, utils } = require('@syuilo/aiscript')
const gcc = require('textarea-caret')
const { v4: uuidv4 } = require('uuid')
global.uuid = uuidv4
global.getCaretCoordinates = gcc
global.sanitizeHtml = require('sanitize-html')
global.asValue = values

View File

@ -9,7 +9,7 @@
"test": "echo \"Error: no test specified\" && exit 1",
"postinstall": "run-s util:*",
"util:hash": "node gitHash.js",
"util:browserify": "browserify aiscript.js -o js/platform/aiscript.js",
"util:browserify": "browserify native.js -o js/platform/native.js",
"construct": "node view/make/makeCli.js",
"construct:store": "node view/make/makeCli.js --store",
"dev": "run-p dev:*",
@ -38,7 +38,8 @@
"url": "https://cutls.dev",
"email": "p@cutls.com"
},
"contributor": [{
"contributor": [
{
"name": "とねぢ",
"url": "https://minohdon.jp/@toneji",
"email": "solfa.tono@gmail.com"
@ -71,6 +72,7 @@
"sweetalert2": "^11.0.17",
"system-font-families": "^0.4.1",
"textarea-caret": "^3.1.0",
"uuid": "^8.3.2",
"vue": "^2.6.14"
},
"devDependencies": {

View File

@ -1055,7 +1055,7 @@
<!--JS-->
<script type="text/javascript" src="../../@@node_base@@/jquery/dist/jquery.js"></script>
<script type="text/javascript" src="../../js/platform/first.js"></script>
<script type="text/javascript" src="../../js/platform/aiscript.js"></script>
<script type="text/javascript" src="../../js/platform/native.js"></script>
<script type="text/javascript" src="../../js/platform/plugin.js"></script>
<script type="text/javascript" src="../../@@node_base@@/materialize-css/dist/js/materialize.js"></script>
<script type="text/javascript" src="../../@@node_base@@/grapheme-splitter/index.js"></script>

View File

@ -683,7 +683,7 @@
apiGet: no
}`, -1)
</script>
<script type="text/javascript" src="../../js/platform/aiscript.js"></script>
<script type="text/javascript" src="../../js/platform/native.js"></script>
<script type="text/javascript" src="../../js/platform/plugin.js"></script>
<script type="text/javascript" src="../../js/common/modal.js"></script>
<script type="text/javascript" src="../../js/common/about.js"></script>

View File

@ -25,8 +25,8 @@
<body class="">
<script>
var ver = '22.2.0 (Koume)'
var gitHash = 'da76c6732db27e91a895277d14fd16f0c1434679'
var ver = '22.3.0 (Koume)'
var gitHash = '679151e8eadafebe68b8c0887e9189caeb94474e'
//betaを入れるとバージョンチェックしない
//var ver="beta";
var acct_id = 0
@ -1055,7 +1055,7 @@
<!--JS-->
<script type="text/javascript" src="../../node_modules/jquery/dist/jquery.js"></script>
<script type="text/javascript" src="../../js/platform/first.js"></script>
<script type="text/javascript" src="../../js/platform/aiscript.js"></script>
<script type="text/javascript" src="../../js/platform/native.js"></script>
<script type="text/javascript" src="../../js/platform/plugin.js"></script>
<script type="text/javascript" src="../../node_modules/materialize-css/dist/js/materialize.js"></script>
<script type="text/javascript" src="../../node_modules/grapheme-splitter/index.js"></script>

View File

@ -645,7 +645,7 @@
class="material-icons left">list</i>Help/Docs</a>
<a href="https://github.com/cutls/TheDesk" class="btn waves-effect black lighten-2" style="width:100%; max-width:40rem;"><i class="fab fa-github left"></i>GitHub</a>
<a href="index.html?mode=user&code=Cutls@1m.cutls.com" class="btn waves-effect blue lighten-2" style="width:100%; max-width:40rem;"><img src="../../img/desk_full.svg" class="left" width="25" style="padding-top:5px;">Main author: Cutls@1m.cutls.com</a>
<br> TheDesk @ <a href="https://github.com/cutls/TheDesk/commits/da76c6732db27e91a895277d14fd16f0c1434679">da76c6732db27e91a895277d14fd16f0c1434679</a> - <a onclick="checkupd(); return localStorage.removeItem('new-ver-skip'); location.href='index.html';" class="pointer pwa">Sprawdź aktualizacje</a><br>
<br> TheDesk @ <a href="https://github.com/cutls/TheDesk/commits/679151e8eadafebe68b8c0887e9189caeb94474e">679151e8eadafebe68b8c0887e9189caeb94474e</a> - <a onclick="checkupd(); return localStorage.removeItem('new-ver-skip'); location.href='index.html';" class="pointer pwa">Sprawdź aktualizacje</a><br>
<br> Kyash
<br>
<img src="../../img/kyash.png" width="100"><br>
@ -653,7 +653,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/da76c6732db27e91a895277d14fd16f0c1434679" alt="FOSSA Status"><img src="https://app.fossa.com/api/projects/git%2Bgithub.com%2Fcutls%2FTheDesk.svg?type=small" /></a>
<a href="https://app.fossa.com/projects/git%2Bgithub.com%2Fcutls%2FTheDesk/refs/branch/master/679151e8eadafebe68b8c0887e9189caeb94474e" alt="FOSSA Status"><img src="https://app.fossa.com/api/projects/git%2Bgithub.com%2Fcutls%2FTheDesk.svg?type=small" /></a>
<br>
<span style="font-family:Open Sans;">Copyright &copy; TheDesk 2018
Under <a href="https://github.com/cutls/TheDesk/blob/master/LICENSE">GNU General Public License v3.0</a> and <a
@ -683,7 +683,7 @@
apiGet: no
}`, -1)
</script>
<script type="text/javascript" src="../../js/platform/aiscript.js"></script>
<script type="text/javascript" src="../../js/platform/native.js"></script>
<script type="text/javascript" src="../../js/platform/plugin.js"></script>
<script type="text/javascript" src="../../js/common/modal.js"></script>
<script type="text/javascript" src="../../js/common/about.js"></script>

View File

@ -5246,6 +5246,11 @@ uuid@^3.3.2:
resolved "https://registry.yarnpkg.com/uuid/-/uuid-3.3.3.tgz#4568f0216e78760ee1dbf3a4d2cf53e224112866"
integrity sha512-pW0No1RGHgzlpHJO1nsVrHKpOEIxkGg1xB+v0ZmdNH5OAeAwzAVrCnI2/6Mtx+Uys6iaylxa+D3g4j63IKKjSQ==
uuid@^8.3.2:
version "8.3.2"
resolved "https://registry.yarnpkg.com/uuid/-/uuid-8.3.2.tgz#80d5b5ced271bb9af6c445f21a1a04c606cefbe2"
integrity sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==
v8-compile-cache@^2.0.3:
version "2.1.1"
resolved "https://registry.yarnpkg.com/v8-compile-cache/-/v8-compile-cache-2.1.1.tgz#54bc3cdd43317bca91e35dcaf305b1a7237de745"