From 56ac5f2afc3dfcff724e39a41b1bde60b6317714 Mon Sep 17 00:00:00 2001 From: Magic Date: Sun, 29 Jan 2023 18:50:04 -0800 Subject: [PATCH] v4.11.19 Signed-off-by: Magic --- .eslintrc.json | 16 +- tools/webpack.config.js | 243 +++++++++++----------- userscript/dist/magic-userjs.user.js | 247 ++++++++++++---------- userscript/src/main.js | 293 ++++++++++++++------------- userscript/src/sass/main.scss | 29 +-- userscript/tools/userscript.mjs | 82 +------- 6 files changed, 451 insertions(+), 459 deletions(-) diff --git a/.eslintrc.json b/.eslintrc.json index a1c3b89..d91817c 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -1,6 +1,7 @@ { "root": true, "globals": { + "MU": "writable", "GM": "writable", "err": "readonly", "browser": "readonly", @@ -33,6 +34,17 @@ "modules": true } }, - "ignorePatterns": ["/src/header.js","/tools/userscript.js", "/dist/*.js"], - "rules": {} + "ignorePatterns": [ + "/src/header.js", + "/tools/userscript.js", + "/tests/*.js", + "/dist/*.js" + ], + "rules": { + "quotes": [ + "error", + "single", + { "avoidEscape": true, "allowTemplateLiterals": false } + ] + } } diff --git a/tools/webpack.config.js b/tools/webpack.config.js index 7c587e2..2bbc313 100644 --- a/tools/webpack.config.js +++ b/tools/webpack.config.js @@ -1,136 +1,141 @@ /* eslint-env node */ -const {merge} = require('webpack-merge'), +const { merge } = require('webpack-merge'), CopyPlugin = require('copy-webpack-plugin'), path = require('path'), TerserPlugin = require('terser-webpack-plugin'), webpack = require('webpack'), -brws = process.env.NODE_ENV, -file = (dir) => path.resolve(path.resolve(__dirname, '..'),dir), -plugins = [ - new webpack.optimize.LimitChunkCountPlugin({ maxChunks: 1 }), - new CopyPlugin({ - patterns: [ - { - from: file(`src/manifest/${brws}.json`), - to: file(`tests/${brws}/manifest.json`), - transform(content) { - const { version, author, homepage: homepage_url } = require('../package.json') - const manifest = JSON.parse(content) - return JSON.stringify( - Object.assign(manifest, { version, author, homepage_url }), - ) +file = (dir) => path.resolve(path.resolve(__dirname, '..'),dir); +module.exports = (env,args) => { + let brws = env.brws, + plugins = [ + new webpack.optimize.LimitChunkCountPlugin({ maxChunks: 1 }), + new CopyPlugin({ + patterns: [ + { + from: file(`src/manifest/${brws}.json`), + to: file(`tests/${brws}/manifest.json`), + transform(content) { + const { version, description, author, homepage: homepage_url } = require('../package.json'); + const manifest = JSON.parse(content); + return JSON.stringify(Object.assign(manifest, { version, description, author, homepage_url }),null,' '); + }, }, - }, - { - from: file('src/locales'), - to: file(`tests/${brws}/_locales`), - }, - // { - // from: file('src/html'), - // to: file(`tests/${brws}`), - // }, - { - from: file('tests/compiled'), - to: file(`tests/${brws}/css`), - }, - { - from: file('src/img'), - to: file(`tests/${brws}/img`), - }, - { - from: file('src/web_accessible_resources'), - to: file(`tests/${brws}/web_accessible_resources`), - force: true, - }, - // { - // from: file('src/js'), - // to: file(`tests/${brws}/js`), - // }, - ], - }), - // new webpackEnv(), -], -commonConfig = { - context: file('src'), - entry: { - // start: './js/start.js', - }, - output: { - path: file(`tests/${brws}/js`), - filename: '[name].js', - }, - module: { - rules: [ - { - test: /\.m?js$/, - exclude: /(node_modules|bower_components)/, - use: { - loader: 'swc-loader', - options: { - sync: true, - jsc: { - parser: { - syntax: 'ecmascript' + { + from: file('src/_locales'), + to: file(`tests/${brws}/_locales`), + }, + { + from: file('src/html'), + to: file(`tests/${brws}`), + }, + { + from: file('tests/compiled'), + to: file(`tests/${brws}/css`), + force: true, + }, + { + from: file('src/img'), + to: file(`tests/${brws}/img`), + }, + { + from: file('src/web_accessible_resources'), + to: file(`tests/${brws}/web_accessible_resources`), + // force: true, + }, + { + from: file('src/js'), + to: file(`tests/${brws}/js`), + // force: true, + }, + { + from: file('src/sass/fonts'), + to: file(`tests/${brws}/css/fonts`), + }, + ], + }), + ], + commonConfig = { + context: file('src'), + entry: { + start: './js/start.js', + }, + output: { + path: file(`tests/${brws}/js`), + filename: '[name].js', + }, + module: { + rules: [ + { + test: /\.m?js$/, + exclude: /(node_modules|bower_components)/, + use: { + loader: 'swc-loader', + options: { + sync: true, + jsc: { + parser: { + syntax: 'ecmascript' + }, + target: 'es2020', + }, + module: { + type: 'es6', }, - target: 'es2020', - }, - module: { - type: 'es6', }, }, }, - }, - ], + ], + }, + resolve: { + extensions: ['.js'], + fallback: { + 'path': require.resolve('path-browserify') + } + }, + plugins, + experiments: {topLevelAwait: true,}, }, - resolve: { - extensions: ['.js'], - fallback: { 'path': require.resolve('path-browserify') } - }, - plugins, -}, -productionConfig = { - mode: 'production', - optimization: { - minimize: true, - minimizer: [ - new TerserPlugin({ - terserOptions: { - format: { - comments: false, + productionConfig = { + mode: 'production', + optimization: { + minimize: true, + minimizer: [ + new TerserPlugin({ + terserOptions: { + format: { + comments: false, + }, }, - }, - extractComments: false, - parallel: true, - })], + extractComments: false, + parallel: true, + })], + }, }, -}, -developmentConfig = { - mode: 'development', - devtool: 'source-map', - optimization: { - minimize: false, - minimizer: [ - new TerserPlugin({ - test: /\.m?js$/, - // minify: TerserPlugin.swcMinify, - terserOptions: { - format: { - comments: true, + developmentConfig = { + mode: 'development', + devtool: 'source-map', + optimization: { + minimize: false, + minimizer: [ + new TerserPlugin({ + // test: /\.m?js$/, + // minify: TerserPlugin.swcMinify, + terserOptions: { + format: { + comments: true, + }, }, - }, - extractComments: true, - parallel: true, - })], - }, - watch: true, - watchOptions: { - poll: 1500, - aggregateTimeout: 500, - ignored: /node_modules/, - }, -}; - -module.exports = (env,args) => { + extractComments: true, + parallel: true, + })], + }, + watch: true, + watchOptions: { + poll: 1000, + aggregateTimeout: 500, + ignored: /node_modules/, + }, + }; switch(args.mode) { case 'development': return merge(commonConfig, developmentConfig); diff --git a/userscript/dist/magic-userjs.user.js b/userscript/dist/magic-userjs.user.js index 9667c16..b043ce7 100644 --- a/userscript/dist/magic-userjs.user.js +++ b/userscript/dist/magic-userjs.user.js @@ -14,7 +14,7 @@ // @description:ru-RU Показывает пользовательские скрипты (UserJS) для сайта. Легкий способ установить пользовательские скрипты для Tampermonkey. // @description:ru Показывает пользовательские скрипты (UserJS) для сайта. Легкий способ установить пользовательские скрипты для Tampermonkey. // @author Magic -// @version 4.10.19 +// @version 4.11.19 // @icon data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGAAAABgCAYAAADimHc4AAAABmJLR0QAAAAAAAD5Q7t/AAAACXBIWXMAAAsTAAALEwEAmpwYAAAAB3RJTUUH3gYRBAceMUIR3QAAEg9JREFUeNrtXWlwVNW2/k4n3RkbM5FRMEHUBOIAekGMJV4lYVDBAeQ+IYTJODAVjwBXfRZFQRn04vthiQgGEOMDiylY4lB6g1CG8VFJLF4SSYiBRBDTSZM06aQzdH/vB+ccex5Id9IBV9WuJDvnnL3P+s7+9tprr723gBsUkkoAEAShG96VQABqAOHiz+EARog/7wAwGECkmMLEe/QAropJA+AigPMAKsWfbQCuianH7B2iAOgFQehEP4kA/xClqOQHANwL4B4AdwEYCiCkl8/uAFAPoAbAOQBnAZQDqALQhVtcEgAsB3AcwG/il0ofpzaxrONi2Qm3ksIFAFEAxgHYDqDVE+VJEhISwoKCAra0tFCj0TA/P9/uddb363Q6/vTTT/Lfw4YNo0KhaBXrMk6sm3CzKj8JwKsAvlGpVO2zZ8/mkSNHePnyZRoMBrsKcwTAnj17aC2LFi1yCYB1/vnz57ljxw7p73YA34h1TLqZFB8MIDcwMLBi6NChHUuXLuXFixdpT9wF4MyZMxw5ciQHDRrEjz/+mCR5+vRpjwGw/jszM5NRUVEdACoA5Ip1H7ASC+A5AP/rLf6WZMyYMXJeQkICSfLatWu9BqCjo4Pfffed+T0lAB4xs7YGjEwRrQ2jNztQSVQqlUeKdfc6B/e1ANgEIG0gKD4QwGYA3QCoUCgoCAIFQWBqaip//fVXOhN3AfBUsQCoUqluFACK73MBwGwACn+mnN0ATEqlki+//DIrKyu5detWJiUlySCcPXuWJpPJpwA0NjaSJBMTE+W8sWPH9gYAKRkA/Et8V7+SvwE4JFFOQkICT58+TZLs7u7mgQMHOGTIEK9RkKv8Y8eOkSQ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tYyPz9fMm9NAApxA+fI3ChaKgBzAeS72gWwv+W67gFB6P2HmZiYiLvvvhtKpRIXLlxAXV0denp6COB/ALwmRjv0mTg9xuoWSUYAa9GHJyjZa0E2B7ndIukygH/ATw6Alo4y7LkFFO9XRxlaD9b+hesnR9ysyvfbwzzN3RazRSdU901kJQ2I42zNJVV0w7YMRAACAgI4c+ZMPv/880xKStIFBAR8hAFyoLP1fMIj1jNr/g5AXFwc33nnHaakpEgzWQPySHPr6c1ccVK63R8BMJlM8hLZMWPGGAIDAyvFOgfjJpIkAK8mJSX9OyMjw6BUKrlx40ZqNBrqdDoeOHCAd9xxh4VyZs2axR9//JFXr151GHkgiauTMKQIhWvXrlGj0fCjjz5iSEgIy8rKpMiOdqVS+a0YOpKEm1QEceQ8DsD2sLAw3YIFC1hSUkKtVsuamhrZPWxvsZ515AHcPAlDilAwGo1sa2tjY2Mjd+3axbS0NAYGBraK4YLjxLoJuIUkAcByQRCOp6WlXVm4cKFh6tSpnDhxIquqqlhVVcXp06czOjqawcHBNpEHcHFyxalTp+Rls/v27eOKFSsYExOjFwThN1wPEV8OJ4Gyt5IocX3BQk5QUNB/x8bGfpeenv6rWq226TOSkpJ44cIFedOPzs5OajQai4OXBw0axGXLlnHChAkE0J6cnHw+Ojr6W1xfFpQjlqXyF0pwKUajMUAQBMV1n5Zg4ehSKBRd4u8q0enVZcchppKudXXdli1bAvfs2aP+448/wvV6fbhOp7uzq6srzWg03knyDpIxJCMBRHR1dYWpVCoA0Hd1dV0FcBWABsDF8PDwOpVKVaXVan8ZOXJkZ1xcXNvhw4ebxZGsRZlSfUwmk0oQBLS3t3eLwVTuOPvsvo+z9zSX/wfl+jWwZp8+ogAAAABJRU5ErkJggg== // @downloadURL https://github.com/magicoflolis/Userscript-Plus/releases/latest/download/magic-userjs.user.js // @updateURL https://github.com/magicoflolis/Userscript-Plus/releases/latest/download/magic-userjs.user.js @@ -45,7 +45,7 @@ * Injected stylesheet * https://github.com/magicoflolis/Userscript-Plus/tree/master/userscript/src/sass */ -const main_css = `html.webext-page,body.webext-page{height:100%;width:100%;padding:0;margin:0;background:#495060;color:#fff}.magicuserjs-body,mujs-column,mujs-row{display:flex}mujs-column,mujs-row{gap:10px}@media screen and (max-width: 800px){mujs-column{flex-flow:row wrap}}.magicuserjs-body,mujs-row{flex-direction:column}magic-userjs{cursor:default}magic-userjs *{line-height:normal}.hidden{display:none !important;z-index:-1 !important}.main{width:100%;width:-moz-available;width:-webkit-fill-available;height:492px;position:fixed;background:#495060 !important;border:1px solid rgba(0,0,0,0);border-radius:10px;font-size:14px !important;font-family:arial,sans-serif !important}@media screen and (max-height: 450px){.main{height:100% !important;bottom:0rem !important;margin-left:0rem !important;margin-right:0rem !important;right:0rem !important}}.main.expanded{height:100% !important;bottom:0rem !important}.main:not(.expanded){margin-left:1rem;margin-right:1rem;right:1rem;bottom:1rem}.main:not(.expanded).auto-height{height:auto}.main:not(.hidden){z-index:100000000000000000 !important;display:flex !important;flex-direction:column !important}.main *:not(magicuserjs-a,magicuserjs-btn,magicuserjs-btn>svg,count-frame,.counterframe,.count,label,.magicuserjs-switch){background:#495060 !important}.main *:not(magicuserjs-a,magicuserjs-btn,magicuserjs-btn>svg,count-frame,.counterframe,.count){color:#fff !important}.counterframe{border-radius:16px;line-height:1;padding:2px;width:25px !important;height:25px !important;margin:auto}.count{background:rgba(0,0,0,0);padding:10%}.mainframe{background:#495060 !important;color:#fff !important;border:2px solid rgba(0,0,0,0);border-radius:100%;padding:.5% !important;position:fixed;bottom:1rem;right:1rem;width:25px !important;height:25px !important}.mainframe:not(.hidden){z-index:100000000000000000 !important;display:block}count-frame{border:2px solid rgba(0,0,0,0);font-size:16px;font-weight:400;display:block;text-align:center;line-height:normal;width:auto;height:auto}.magicuserjs-header{order:0;display:flex;gap:10px;border-bottom:1px solid #fff;border-top-left-radius:10px;border-top-right-radius:10px;height:-webkit-fit-content;height:-moz-fit-content;height:fit-content;padding:10px;font-size:1em;place-content:space-between}body.webext-page,.magicuserjs-body{overflow-x:hidden;order:1}html.webext-page,body.webext-page,.magicuserjs-cfg,.magicuserjs-body{scrollbar-color:#fff #2e323d;scrollbar-width:thin;border:1px solid rgba(0,0,0,0);border-bottom-left-radius:10px;border-bottom-right-radius:10px}.magicuserjs-cfg{height:-webkit-fit-content;height:-moz-fit-content;height:fit-content;order:2}@media screen and (max-width: 1150px){.magicuserjs-cfg{margin:0px auto 1rem auto !important}}@media screen and (max-height: 812px){.magicuserjs-cfg:not(.webext-page){flex-wrap:wrap;flex-direction:row !important}}.magicuserjs-cfg mujs-section>label{display:flex;justify-content:space-between;padding:.5em}.magicuserjs-cfg mujs-section>label input[type*=number]{position:relative;border-radius:4px;border:1px solid #fff}.magicuserjs-cfg .magicuserjs-inlab{position:relative;width:38px;border-radius:20px}.magicuserjs-cfg .magicuserjs-inlab input[type*=checkbox]{display:none}.magicuserjs-cfg .magicuserjs-inlab input[type*=checkbox]:checked+label{margin-left:0;background-color:rgba(255,255,255,.568)}.magicuserjs-cfg .magicuserjs-inlab input[type*=checkbox]:checked+label:before{right:0px}.magicuserjs-cfg .magicuserjs-inlab input[type*=checkbox]#greasyfork:checked+label,.magicuserjs-cfg .magicuserjs-inlab input[type*=checkbox]#sleazyfork:checked+label{background-color:rgba(0,183,255,.568)}.magicuserjs-cfg .magicuserjs-inlab input[type*=checkbox]#openuserjs:checked+label{background-color:rgba(237,63,20,.568)}.magicuserjs-cfg .magicuserjs-inlab input[type*=checkbox]#github:checked+label{background-color:rgba(36,41,47,.568)}.magicuserjs-cfg .magicuserjs-inlab label{display:block;overflow:hidden;height:16px;padding:0;border-radius:20px;border:1px solid #fff;background-color:#495060}.magicuserjs-cfg .magicuserjs-inlab label:before{content:"";display:block;width:20px;height:20px;margin:-2px;background:#fff;position:absolute;top:0;right:20px;border-radius:20px}.magicuserjs-cfg .webext-page{height:900px}.magicuserjs-cfg:not(.webext-page){margin:0px 25rem 1rem 25rem}.magicuserjs-eframe,.frame{display:grid;grid-auto-flow:column;grid-auto-columns:1fr;font-size:1em}.frame{border-bottom:1px solid #fff}@media screen and (max-width: 800px){.frame{display:flow-root !important;height:-webkit-fit-content !important;height:-moz-fit-content !important;height:fit-content !important}}.frame magicuserjs-btn svg{fill:#fff;width:14px;height:14px}.frame:not(.sf) magicuserjs-a{color:#00b7ff !important}.frame:not(.sf) magicuserjs-btn{color:#fff;background-color:#2d8cf0;border-color:#2d8cf0}.frame.sf magicuserjs-a{color:#e75531 !important}.frame.sf magicuserjs-btn{background-color:#ed3f14 !important;border-color:#ed3f14 !important}.magicuserjs-name{font-size:inherit !important;display:grid;margin-left:1%;margin-top:.67em;margin-bottom:.67em}.magicuserjs-name span{font-size:.8em !important}.magicuserjs-eframe{margin-right:1%;margin-top:.67em;margin-bottom:.67em}@media screen and (max-width: 800px){.magicuserjs-eframe{height:-webkit-fit-content !important;height:-moz-fit-content !important;height:fit-content !important}}.magicuserjs-uframe{display:grid;grid-auto-flow:column;grid-gap:1em}mujs-btn{font-style:normal;font-weight:400;font-variant:normal;text-transform:none;text-rendering:auto;border:1px solid #fff;font-size:16px;border-radius:4px;line-height:1;padding:6px 15px}mujs-btn svg{fill:#fff;width:14px;height:14px}input[type*=number],input[type*=text]{border:rgba(0,0,0,0);outline:none !important}magicuserjs-btn{font-size:14px;border-radius:4px;font-style:normal;padding:7px 15%;font-weight:400;font-variant:normal;line-height:normal}magicuserjs-a,magicuserjs-btn,.magicuserjs-cfg mujs-section *:not(input[type*=text],input[type*=number]),.mainbtn,.mainframe,mujs-btn{cursor:pointer !important}.magicuserjs-cfg *:not(input[type*=text],input[type*=number]){-webkit-user-select:none !important;-moz-user-select:none !important;-ms-user-select:none !important;user-select:none !important}mujs-btn,input,.magicuserjs-uframe,.magicuserjs-list,.install,.magicuserjs-homepage{width:-webkit-fit-content;width:-moz-fit-content;width:fit-content;height:-webkit-fit-content;height:-moz-fit-content;height:fit-content}`; +const main_css = '*{scrollbar-color:#fff #2e323d;scrollbar-width:thin}@supports not (scrollbar-width: thin){* ::-webkit-scrollbar{width:1.4vw;height:3.3vh}* ::-webkit-scrollbar-track{background-color:#2e323d;border-radius:10px;margin-top:3px;margin-bottom:3px;box-shadow:inset 0 0 6px rgba(0,0,0,.3)}* ::-webkit-scrollbar-thumb{border-radius:10px;background-color:#fff;background-image:-webkit-linear-gradient(45deg, rgba(255, 255, 255, 0.2) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.2) 50%, rgba(255, 255, 255, 0.2) 75%, transparent 75%, transparent)}* ::-webkit-scrollbar-thumb:hover{background-color:#fff}}*:not(.mujs-iframe){background:#495060;color:#fff}magic-userjs{line-height:normal}.magicuserjs-cfg{line-height:1.5}body.webext-page,.main{font-size:14px}.magicuserjs-body,mujs-column,mujs-row{display:flex}mujs-column,mujs-row{gap:10px}@media screen and (max-width: 800px){mujs-column{flex-flow:row wrap}}.magicuserjs-body,mujs-row{flex-direction:column}magic-userjs{cursor:default}.hidden{display:none !important;z-index:-1 !important}.main{width:100%;width:-moz-available;width:-webkit-fill-available;background:#495060 !important;border:1px solid rgba(0,0,0,0);border-radius:10px;font-family:Arial,Helvetica,sans-serif}@media screen and (max-height: 450px){.main:not(.webext-page){height:100% !important;bottom:0rem !important;margin-left:0rem !important;margin-right:0rem !important;right:0rem !important}}.main.expanded{height:100% !important;bottom:0rem !important}.main:not(.webext-page){position:fixed;height:492px}.main:not(.webext-page):not(.expanded){margin-left:1rem;margin-right:1rem;right:1rem;bottom:1rem}.main:not(.webext-page):not(.expanded).auto-height{height:auto}.main:not(.hidden){z-index:100000000000000000 !important;display:flex !important;flex-direction:column !important}.count{background:rgba(0,0,0,0)}.mainframe{background:rgba(0,0,0,0);position:fixed;bottom:1rem;right:1rem}.mainframe:not(.hidden){z-index:100000000000000000 !important;display:block}.mainframe count-frame{width:2em;height:1em}count-frame{border-radius:16px;padding:0 .25em;border:2px solid rgba(0,0,0,0);font-size:16px;font-weight:400;display:inline-block;text-align:center;min-width:1em}.magicuserjs-header{order:0;display:flex;gap:10px;border-bottom:1px solid #fff;border-top-left-radius:10px;border-top-right-radius:10px;height:-webkit-fit-content;height:-moz-fit-content;height:fit-content;padding:10px;font-size:1em;place-content:space-between}.magicuserjs-body{overflow-x:hidden;order:1}.magicuserjs-cfg,.magicuserjs-body{scrollbar-color:#fff #2e323d;scrollbar-width:thin;border:1px solid rgba(0,0,0,0);border-bottom-left-radius:10px;border-bottom-right-radius:10px}@media screen and (max-width: 1150px){.magicuserjs-cfg{margin:0px auto 1rem auto !important}}.magicuserjs-cfg{height:-webkit-fit-content;height:-moz-fit-content;height:fit-content}@media screen and (max-height: 812px){.magicuserjs-cfg:not(.webext-page){flex-wrap:wrap;flex-direction:row !important}}.magicuserjs-cfg mujs-section>label{display:flex;justify-content:space-between}.magicuserjs-cfg mujs-section>label input[type*=number]{position:relative;border-radius:4px;border:1px solid #fff}.magicuserjs-cfg .magicuserjs-inlab{position:relative;width:38px}.magicuserjs-cfg .magicuserjs-inlab input[type*=checkbox]{display:none}.magicuserjs-cfg .magicuserjs-inlab input[type*=checkbox]:checked+label{margin-left:0;background-color:rgba(255,255,255,.568)}.magicuserjs-cfg .magicuserjs-inlab input[type*=checkbox]:checked+label:before{right:0px}.magicuserjs-cfg .magicuserjs-inlab input[type*=checkbox]#greasyfork:checked+label,.magicuserjs-cfg .magicuserjs-inlab input[type*=checkbox]#sleazyfork:checked+label{background-color:rgba(0,183,255,.568)}.magicuserjs-cfg .magicuserjs-inlab input[type*=checkbox]#openuserjs:checked+label{background-color:rgba(237,63,20,.568)}.magicuserjs-cfg .magicuserjs-inlab input[type*=checkbox]#github:checked+label{background-color:rgba(36,41,47,.568)}.magicuserjs-cfg .magicuserjs-inlab label{padding:0;display:block;overflow:hidden;height:16px;border-radius:20px;border:1px solid #fff;background-color:#495060}.magicuserjs-cfg .magicuserjs-inlab label:before{content:"";display:block;width:20px;height:20px;margin:-2px;background:#fff;position:absolute;top:0;right:20px;border-radius:20px}.magicuserjs-cfg #blacklist{overflow-y:auto;background:#000;color:#fff;resize:vertical;outline:none;border-style:none;font-family:monospace}.magicuserjs-cfg #blacklist:focus{outline:none}.magicuserjs-cfg:not(.webext-page){order:2;margin:0px 25rem 1rem 25rem}.frame{display:flex;gap:1rem;border-bottom:1px solid #fff;padding:.67em .5em}@media screen and (max-width: 800px){.frame:not(.webext-page){display:flow-root !important;height:-webkit-fit-content !important;height:-moz-fit-content !important;height:fit-content !important}}.frame>magic-userjs{align-self:center}.frame>magic-userjs.install-btn{flex:1}.frame>magic-userjs.magicuserjs-list{flex:1}.frame .magicuserjs-ratings{padding:0 .25em;border:1px solid #fff;border-radius:10px}.frame magicuserjs-btn svg{fill:#fff;width:14px;height:14px;background:rgba(0,0,0,0)}.frame.sf magicuserjs-a{color:#e75531 !important}.frame.sf magicuserjs-btn{background-color:#ed3f14 !important;border-color:#ed3f14 !important}.frame:not(.sf) magicuserjs-a{color:#00b7ff !important}.frame:not(.sf) magicuserjs-btn{color:#fff;background-color:#2d8cf0;border-color:#2d8cf0}.magicuserjs-name{flex:3;display:grid}.magicuserjs-name span{font-size:.8em !important}.magicuserjs-uframe{flex:1;display:grid;grid-auto-flow:column;grid-gap:1em}mujs-btn{font-style:normal;font-weight:400;font-variant:normal;text-transform:none;text-rendering:auto;border:1px solid #fff;font-size:16px;border-radius:4px;line-height:1;padding:6px 15px}mujs-btn svg{fill:#fff;width:14px;height:14px}magicuserjs-btn{font-size:14px;border-radius:4px;font-style:normal;padding:7px 15%;font-weight:400;font-variant:normal;line-height:normal}input[type*=number],input[type*=text]{border:rgba(0,0,0,0);outline:none !important}magicuserjs-a,magicuserjs-btn,.magicuserjs-cfg mujs-section *:not(input[type*=text],input[type*=number]),.mainbtn,.mainframe,mujs-btn{cursor:pointer !important}.magicuserjs-cfg *:not(input[type*=text],input[type*=number]){-webkit-user-select:none !important;-moz-user-select:none !important;-ms-user-select:none !important;user-select:none !important}mujs-btn,input,.magicuserjs-uframe,.magicuserjs-list,.magicuserjs-homepage{width:-webkit-fit-content;width:-moz-fit-content;width:fit-content;height:-webkit-fit-content;height:-moz-fit-content;height:fit-content}'; (() => { const win = window, @@ -109,7 +109,6 @@ class MUError extends Error { }; }; -// TODO: Add tabs allowing the ability to search multiple sites @ once let langs = { en: { daily: 'Daily Installs', @@ -228,6 +227,7 @@ let langs = { created: 'Créé', redirect: 'Greasy Fork pour les adultes', filter: 'Filtrer les autres langues', + // eslint-disable-next-line quotes dtime: `Délai d'affichage`, save: 'Sauvez', }, @@ -264,7 +264,7 @@ defcfg = { cache: true, autoexpand: false, filterlang: false, - sleazyredirct: false, + sleazyredirect: false, time: 10000, blacklist: [ { @@ -338,10 +338,7 @@ MU = { if(isGM) { resolve(JSON.parse( GM_getValue(key,def) )); }; - if(!key.includes('Config')) { - resolve(JSON.parse( win.localStorage.getItem(key) )); - }; - resolve(JSON.parse( win.localStorage.getItem(`MUJS${key}`) ?? def )); + resolve(win.localStorage.getItem(`MUJS${key}`) ? JSON.parse( win.localStorage.getItem(`MUJS${key}`) ) : def); }); }, info: { @@ -513,24 +510,25 @@ make = (element, cname, attrs = {}) => { } catch(ex) {handleError(ex)} }, iconSVG = { - cfg: ` `, - close: ``, - filter: ` `, - fsClose: ` `, - fsOpen: ` `, - fullscreen: ``, - gf: ``, - gh: ``, - hide: ` `, - install: ``, - issue: ``, - nav: ` `, - plus: ` `, - search: ` `, + cfg: ' ', + close: '', + filter: ' ', + fsClose: ' ', + fsOpen: ' ', + fullscreen: '', + gf: '', + gh: '', + hide: ' ', + install: '', + issue: '', + nav: ' ', + plus: ' ', + search: ' ', }, container = make('main-userjs','mujs-primary'), ifram = make('iframe','mujs-iframe', { src: 'about:blank', + style: 'position: fixed; bottom: 1rem; right: 1rem; height: 525px; width: 90%; margin-left: 1rem; margin-right: 1rem; z-index: 100000000000000020 !important;' }); function main() { @@ -541,7 +539,7 @@ function main() { thisHost = location.hostname.split('.').splice(-2).join('.'); const save = () => { try { - MU.setValue('Config',cfg); + MU.setValue('Config', cfg); unsaved = false; log('Saved:',cfg); } catch(e) {err(e)}; @@ -599,17 +597,24 @@ function main() { ftotal = make('magic-userjs','magicuserjs-list', { innerHTML: `${lang.total}: ${ujs.total_installs}`, }), - fgood = make('magic-userjs','magicuserjs-list', { + fratings = make('magic-userjs','magicuserjs-list', { + title: lang.rating, + innerHTML: `${lang.rating}:`, + }), + fgood = make('magic-userjs','magicuserjs-list magicuserjs-ratings', { title: lang.good, - innerHTML: `${lang.rating}: ${ujs.good_ratings}`, + innerHTML: ujs.good_ratings, + style: 'border-color: rgb(51, 155, 51); background-color: #339b331a; color: #339b33;', }), - fok = make('magic-userjs','magicuserjs-list', { + fok = make('magic-userjs','magicuserjs-list magicuserjs-ratings', { title: lang.ok, innerHTML: ujs.ok_ratings, + style: 'border-color: rgb(155, 155, 0); background-color: #9b9b001a; color: #9b9b00;', }), - fbad = make('magic-userjs','magicuserjs-list', { + fbad = make('magic-userjs','magicuserjs-list magicuserjs-ratings', { title: lang.bad, innerHTML: ujs.bad_ratings, + style: 'border-color: red; background-color: #9b33331a; color: red;', }), fdesc = make('magic-userjs','magicuserjs-list', { style: 'cursor: pointer; margin-top: 3px;', @@ -624,7 +629,7 @@ function main() { } }, }), - eframe = make('magic-userjs','magicuserjs-eframe'), + eframe = make('magic-userjs', 'install-btn'), uframe = make('magic-userjs','magicuserjs-uframe'), fdaily = make('magic-userjs','magicuserjs-list', { title: lang.daily, @@ -652,10 +657,10 @@ function main() { }); uframe.append(user); }; - eframe.append(uframe,fdaily,fupdated,fdwn); - fmore.append(ftotal,fgood,fok,fbad,fver,fcreated); + eframe.append(fdwn); + fmore.append(ftotal,fratings,fgood,fok,fbad,fver,fcreated); fname.append(ftitle,fdesc,fmore); - frame.append(fname,eframe); + frame.append(fname,uframe,fdaily,fupdated,eframe); sh('.magicuserjs-body').append(frame); }; if(!isEmpty(navigator.languages)) { @@ -667,7 +672,7 @@ function main() { }; }; try { - if(/greasyfork\.org/.test(doc.location.hostname) && cfg.sleazyredirct) { + if(/greasyfork\.org/.test(doc.location.hostname) && cfg.sleazyredirect) { let otherSite = /greasyfork\.org/.test(document.location.hostname) ? 'sleazyfork' : 'greasyfork'; qs('span.sign-in-link') ? /scripts\/\d+/.test(document.location.href) ? !qs('#script-info') && (otherSite == 'greasyfork' || qs('div.width-constraint>section>p>a')) ? location.href = location.href.replace(/\/\/([^.]+\.)?(greasyfork|sleazyfork)\.org/, '//$1' + otherSite + '.org') : false : false : false; }; @@ -712,7 +717,7 @@ function main() { }; } else { inp.checked = cfg[nm]; - if(nm.match(/(autoexpand|sleazyredirct)/gi)) { + if(nm.match(/(autoexpand|sleazyredirect)/gi)) { ael(inp,'change', (e) => { unsaved = true; cfg[nm] = e.target.checked; @@ -733,17 +738,15 @@ function main() { return inp; }, countframe = make('mujs-column'), - gfcountframe = make('magic-userjs', 'counterframe', { - style: 'background: #00b7ff;' - }), - sfcountframe = make('magic-userjs', 'counterframe', { - style: 'background: #ed3f14;' - }), + gfcountframe = make('magic-userjs', 'counterframe'), + sfcountframe = make('magic-userjs', 'counterframe'), gfcounter = make('count-frame','count', { title: 'https://greasyfork.org + https://sleazyfork.org', + style: 'background: #00b7ff;' }), sfcounter = make('count-frame','count', { title: 'https://openuserjs.org', + style: 'background: #ed3f14;' }), buildlist = async (host) => { try { @@ -763,10 +766,12 @@ function main() { code_url: 'about:blank', created_at: Date.now(), code_updated_at: Date.now(), - users: [{ - name: '', - url: '', - }] + users: [ + { + name: '', + url: '', + } + ] }; let sites = [], custom = [], @@ -777,43 +782,84 @@ function main() { if(alang.length > 1) { for(let a of alang) { urls.push(`${i.url}/${a}/scripts/by-site/${host}.json`); - sites.push(MU.fetchURL(`${i.url}/${a}/scripts/by-site/${host}.json`),); + sites.push(MU.fetchURL(`${i.url}/${a}/scripts/by-site/${host}.json?page=1`),); }; - } else { - urls.push(`${i.url}/${clang}/scripts/by-site/${host}.json`); - sites.push(MU.fetchURL(`${i.url}/${clang}/scripts/by-site/${host}.json`),); + continue; }; - } else { - urls.push(`${i.url}/scripts/by-site/${host}.json`); - sites.push(MU.fetchURL(`${i.url}/scripts/by-site/${host}.json`),); - } - }; - if(i.url.match(/(openuserjs.org|github.com)/gi)) { + urls.push(`${i.url}/${clang}/scripts/by-site/${host}.json`); + sites.push(MU.fetchURL(`${i.url}/${clang}/scripts/by-site/${host}.json?page=1`),); + continue; + }; + urls.push(`${i.url}/scripts/by-site/${host}.json`); + sites.push(MU.fetchURL(`${i.url}/scripts/by-site/${host}.json`),); + } else if(i.url.match(/(openuserjs.org|github.com)/gi)) { urls.push(`${i.url}${host}`); custom.push(MU.fetchURL(`${i.url}${host}`,'GET','text'),); }; }; info('Fetching data',host); - let data = await Promise.all(sites).catch((e) => {throw new MUError('Data',e)}); - if(data) { - for(let d of data) { - for(let ujs of d) { - if(ujs.deleted) continue; - if(cfg.filterlang) { - if(alang.length > 1) { - for(let a of alang) { - if(!ujs.locale.includes(a)) continue; - }; - } else if(!ujs.locale.includes(clang)) continue; + if(!isBlank(sites)) { + let hideData = []; + let data = await Promise.all(sites).catch((e) => {throw new MUError('Data',e)}), + joinData = [...new Set([...data[0], ...data[1]])], + filterDeleted = joinData.filter(ujs => !ujs.deleted), + filterLang = cfg.filterlang ? filterDeleted.filter((d) => { + let dlocal = d.locale.split('-')[0] ?? d.locale; + if(alang.length > 1) { + for(let a of alang) { + if(dlocal.includes(a)) { + return true; + }; }; - siteujs.push( - { - url: ujs, - sleazy: false, - }, - ); - sitegfcount++; + } else if(dlocal.includes(clang)) { + return true; }; + hideData.push(d); + return false; + }) : filterDeleted, + finalList = filterLang; + + if(!isBlank(hideData)) { + let hds = []; + for(let h of hideData) { + let txt = await MU.fetchURL(h.code_url,'GET','text'); + let headers = txt.match(/\/\/\s@[\w][\s\S]+/gi) || []; + if(headers.length > 0) { + let regName = new RegExp(`// @name:${clang}\\s+.+`,'gi'), + findName = headers[0].match(regName) || []; + if(isEmpty(findName)) { + continue; + }; + let cReg = new RegExp(`// @name:${clang}\\s+`,'gi'), + cutName = findName[0].replace(cReg, ''); + Object.assign(h, { + name: cutName + }); + + let regDesc = new RegExp(`// @description:${clang}\\s+.+`,'gi'), + findDesc = headers[0].match(regDesc) || []; + if(isEmpty(findDesc)) { + continue; + }; + let dReg = new RegExp(`// @description:${clang}\\s+`,'gi'), + cutDesc = findDesc[0].replace(dReg, ''); + Object.assign(h, { + description: cutDesc + }); + hds.push(h); + }; + }; + finalList = [...new Set([...hds, ...filterLang])]; + }; + + for(let ujs of finalList) { + siteujs.push( + { + url: ujs, + sleazy: false, + }, + ); + sitegfcount++; }; for(let ujs of siteujs) { createjs(ujs.url,ujs.sleazy); @@ -832,20 +878,22 @@ function main() { if(qs('.col-sm-8 .tr-link',selected)) { for(let i of qsA('.col-sm-8 .tr-link',selected)) { await query('.script-version',i); - let fixurl = qs('.tr-link-a',i).href.replaceAll(doc.location.origin,'https://openuserjs.org'), + let fixurl = qs('.tr-link-a',i).href.replace(new RegExp(doc.location.origin, 'gi'),'https://openuserjs.org'), layout = { name: qs('.tr-link-a',i).textContent, description: qs('p',i).textContent, version: qs('.script-version',i).textContent, url: fixurl, - code_url: `${fixurl.replaceAll('/scripts','/install')}.user.js`, + code_url: `${fixurl.replace(new RegExp('/scripts', 'gi'),'/install')}.user.js`, total_installs: qs('td:nth-child(2) p',i).textContent, created_at: qs('td:nth-child(4) time',i).getAttribute('datetime'), code_updated_at: qs('td:nth-child(4) time',i).getAttribute('datetime'), - users: [{ - name: qs('.inline-block a',i).textContent, - url: qs('.inline-block a',i).href, - }] + users: [ + { + name: qs('.inline-block a',i).textContent, + url: qs('.inline-block a',i).href, + } + ] }; for(const key in template) { if(!Object.hasOwn(layout, key)) { @@ -861,7 +909,7 @@ function main() { if(qs('.repo-list-item',selected)) { for(let r of qsA('.repo-list-item',selected)) { let layout = {}, - fixurl = qs('a',r).href.replaceAll(doc.location.origin,'https://github.com'); + fixurl = qs('a',r).href.replace(new RegExp(doc.location.origin, 'gi'),'https://github.com'); layout = Object.assign(layout, { name: qs('a',r).textContent, description: qs('p.mb-1',r).textContent.trim(), @@ -889,14 +937,14 @@ function main() { for(let g of qsA('div.gist-snippet',selected)) { if(qs('span > a:nth-child(2)',g).textContent.includes('.user.js')) { let layout = {}, - fixurl = qs('span > a:nth-child(2)',g).href.replaceAll(doc.location.origin,'https://gist.github.com'); + fixurl = qs('span > a:nth-child(2)',g).href.replace(new RegExp(doc.location.origin, 'gi'),'https://gist.github.com'); layout = Object.assign(layout, { url: fixurl, code_url: `${fixurl}/raw/${qs('span > a:nth-child(2)',g).textContent}`, created_at: qs('time-ago.no-wrap',g).getAttribute('datetime'), users: [{ name: qs('span > a[data-hovercard-type]',g).textContent, - url: qs('span > a[data-hovercard-type]',g).href.replaceAll(doc.location.origin,'https://gist.github.com'), + url: qs('span > a[data-hovercard-type]',g).href.replace(new RegExp(doc.location.origin, 'gi'),'https://gist.github.com'), }] }); for(let i of qsA('.file-box table tr .blob-code',g)) { @@ -950,7 +998,7 @@ function main() { sfcount: sitesfcount, }); }; - if(isBlank(data) && isBlank(custom)) showError('No available UserJS for this webpage'); + if(isBlank(sites) && isBlank(custom)) showError('No available UserJS for this webpage'); } catch(ex) { showError(ex); }; @@ -1029,7 +1077,7 @@ function main() { }, }); makerow(lang.redirect,'checkbox','sleazyredirect'); - makerow(lang.filter,'checkbox','filter'); + makerow(lang.filter,'checkbox','filterlang'); makerow('Greasy Fork','checkbox','greasyfork'); makerow('Sleazy Fork','checkbox','sleazyfork'); makerow('Open UserJS','checkbox','openuserjs'); @@ -1074,9 +1122,9 @@ function main() { isvalid = true; e.target.setAttribute('style',''); }; - } catch(error) { + } catch(ex) { isvalid = false; - err(error); + err(ex); }; }, }), @@ -1100,7 +1148,7 @@ function main() { rebuild = false; preBuild(); }; - if(/greasyfork\.org/.test(doc.location.hostname) && cfg.sleazyredirct) { + if(/greasyfork\.org/.test(doc.location.hostname) && cfg.sleazyredirect) { let otherSite = /greasyfork\.org/.test(document.location.hostname) ? 'sleazyfork' : 'greasyfork'; qs('span.sign-in-link') ? /scripts\/\d+/.test(document.location.href) ? !qs('#script-info') && (otherSite == 'greasyfork' || qs('div.width-constraint>section>p>a')) ? location.href = location.href.replace(/\/\/([^.]+\.)?(greasyfork|sleazyfork)\.org/, '//$1' + otherSite + '.org') : false : false : false; }; @@ -1109,8 +1157,9 @@ function main() { resetbtn = make('mujs-btn', 'reset', { style: 'margin: auto;', innerHTML: 'Reset', - onclick: async (e) => { + onclick: (e) => { halt(e); + MU.setValue('Config'); unsaved = true; cfg = defcfg; txta.value = JSON.stringify(cfg.blacklist, null, ' '); @@ -1151,11 +1200,11 @@ function main() { btnfullscreen.classList.remove('expanded'); main.classList.remove('expanded'); btnfullscreen.innerHTML = fcopen; - } else { - btnfullscreen.classList.add('expanded'); - main.classList.add('expanded'); - btnfullscreen.innerHTML = fcclose; + return; }; + btnfullscreen.classList.add('expanded'); + main.classList.add('expanded'); + btnfullscreen.innerHTML = fcclose; } }), mainframe = make('magic-userjs','mainframe', { @@ -1344,20 +1393,12 @@ function containerInject() { container.attachShadow({mode: 'open'}); return main(); }; - let ifcss = make('style', 'frame-stylesheet', { - innerHTML: `iframe.mujs-iframe { - position: fixed; - bottom: 1rem; - right: 1rem; - height: 525px; - width: 90%; - margin-left: 1rem; - margin-right: 1rem; - z-index: 100000000000000020 !important; - }`, + ael(ifram, 'load', () => { + ifram.contentDocument.documentElement.classList.add('mujs-iframe'); + ifram.contentDocument.body.classList.add('mujs-iframe'); + main(); }); - ifram.onload = main; - doc.body.append(ifcss,ifram); + doc.body.append(ifram); } catch(ex) {handleError(ex)} }; diff --git a/userscript/src/main.js b/userscript/src/main.js index 3a76dec..efb1f96 100644 --- a/userscript/src/main.js +++ b/userscript/src/main.js @@ -1,36 +1,4 @@ const win = window, -// /** -// * Network Format Bytes -// * @param {number} bytes - Number of total bytes -// * @param {number} decimals - toFixed decimal point -// * @example Example usage -// * // returns 1 KB -// * formatBytes(1024); // OR formatBytes(1024,2); -// * @returns {string} Formated bytes -// */ -// formatBytes = (bytes, decimals = 2) => { -// if (!+bytes) return '0 Bytes'; -// const k = 1024, -// dm = decimals < 0 ? 0 : decimals, -// sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'], -// i = Math.floor(Math.log(bytes) / Math.log(k)); -// return `${parseFloat((bytes / Math.pow(k, i)).toFixed(dm))} ${sizes[i]}`; -// }, -// /** -// * Network Progress Indicator -// * @param {Object} evt - Onprogress event for XHR -// * @example Example usage -// * // returns 1% -// * pbar({total: ..., loaded: 1024}); -// * // returns 1 KB -// * pbar({total: 0, loaded: 1024}); -// * @returns {string} Returns bytes, if evt.total === 0 then file size format, otherwise % format -// */ -// pbar = (evt) => { -// let forumla = Object.is(evt.total,0) ? formatBytes(evt.loaded) : `${+(evt.loaded / evt.total * 100).toFixed(2)}%`; -// dbg(forumla); -// return forumla; -// }, /** * Object is Null * @param {Object} obj - Object @@ -210,6 +178,7 @@ let langs = { created: 'Créé', redirect: 'Greasy Fork pour les adultes', filter: 'Filtrer les autres langues', + // eslint-disable-next-line quotes dtime: `Délai d'affichage`, save: 'Sauvez', }, @@ -246,7 +215,7 @@ defcfg = { cache: true, autoexpand: false, filterlang: false, - sleazyredirct: false, + sleazyredirect: false, time: 10000, blacklist: [ { @@ -320,10 +289,7 @@ MU = { if(isGM) { resolve(JSON.parse( GM_getValue(key,def) )); }; - if(!key.includes('Config')) { - resolve(JSON.parse( win.localStorage.getItem(key) )); - }; - resolve(JSON.parse( win.localStorage.getItem(`MUJS${key}`) ?? def )); + resolve(win.localStorage.getItem(`MUJS${key}`) ? JSON.parse( win.localStorage.getItem(`MUJS${key}`) ) : def); }); }, info: { @@ -495,24 +461,25 @@ make = (element, cname, attrs = {}) => { } catch(ex) {handleError(ex)} }, iconSVG = { - cfg: ` `, - close: ``, - filter: ` `, - fsClose: ` `, - fsOpen: ` `, - fullscreen: ``, - gf: ``, - gh: ``, - hide: ` `, - install: ``, - issue: ``, - nav: ` `, - plus: ` `, - search: ` `, + cfg: ' ', + close: '', + filter: ' ', + fsClose: ' ', + fsOpen: ' ', + fullscreen: '', + gf: '', + gh: '', + hide: ' ', + install: '', + issue: '', + nav: ' ', + plus: ' ', + search: ' ', }, container = make('main-userjs','mujs-primary'), ifram = make('iframe','mujs-iframe', { src: 'about:blank', + style: 'position: fixed; bottom: 1rem; right: 1rem; height: 525px; width: 90%; margin-left: 1rem; margin-right: 1rem; z-index: 100000000000000020 !important;' }); function main() { @@ -523,7 +490,7 @@ function main() { thisHost = location.hostname.split('.').splice(-2).join('.'); const save = () => { try { - MU.setValue('Config',cfg); + MU.setValue('Config', cfg); unsaved = false; log('Saved:',cfg); } catch(e) {err(e)}; @@ -540,7 +507,6 @@ function main() { }, sh = elem => injCon.querySelector(elem), shA = elem => injCon.querySelectorAll(elem), - // clk = e => e.dispatchEvent(new MouseEvent('click')), showError = (msg) => { err(msg); let txt = make('mujs-row','error', { @@ -582,17 +548,24 @@ function main() { ftotal = make('magic-userjs','magicuserjs-list', { innerHTML: `${lang.total}: ${ujs.total_installs}`, }), - fgood = make('magic-userjs','magicuserjs-list', { + fratings = make('magic-userjs','magicuserjs-list', { + title: lang.rating, + innerHTML: `${lang.rating}:`, + }), + fgood = make('magic-userjs','magicuserjs-list magicuserjs-ratings', { title: lang.good, - innerHTML: `${lang.rating}: ${ujs.good_ratings}`, + innerHTML: ujs.good_ratings, + style: 'border-color: rgb(51, 155, 51); background-color: #339b331a; color: #339b33;', }), - fok = make('magic-userjs','magicuserjs-list', { + fok = make('magic-userjs','magicuserjs-list magicuserjs-ratings', { title: lang.ok, innerHTML: ujs.ok_ratings, + style: 'border-color: rgb(155, 155, 0); background-color: #9b9b001a; color: #9b9b00;', }), - fbad = make('magic-userjs','magicuserjs-list', { + fbad = make('magic-userjs','magicuserjs-list magicuserjs-ratings', { title: lang.bad, innerHTML: ujs.bad_ratings, + style: 'border-color: red; background-color: #9b33331a; color: red;', }), fdesc = make('magic-userjs','magicuserjs-list', { style: 'cursor: pointer; margin-top: 3px;', @@ -607,7 +580,7 @@ function main() { } }, }), - eframe = make('magic-userjs','magicuserjs-eframe'), + eframe = make('magic-userjs', 'install-btn'), uframe = make('magic-userjs','magicuserjs-uframe'), fdaily = make('magic-userjs','magicuserjs-list', { title: lang.daily, @@ -635,10 +608,10 @@ function main() { }); uframe.append(user); }; - eframe.append(uframe,fdaily,fupdated,fdwn); - fmore.append(ftotal,fgood,fok,fbad,fver,fcreated); + eframe.append(fdwn); + fmore.append(ftotal,fratings,fgood,fok,fbad,fver,fcreated); fname.append(ftitle,fdesc,fmore); - frame.append(fname,eframe); + frame.append(fname,uframe,fdaily,fupdated,eframe); sh('.magicuserjs-body').append(frame); }; if(!isEmpty(navigator.languages)) { @@ -650,7 +623,7 @@ function main() { }; }; try { - if(/greasyfork\.org/.test(doc.location.hostname) && cfg.sleazyredirct) { + if(/greasyfork\.org/.test(doc.location.hostname) && cfg.sleazyredirect) { let otherSite = /greasyfork\.org/.test(document.location.hostname) ? 'sleazyfork' : 'greasyfork'; qs('span.sign-in-link') ? /scripts\/\d+/.test(document.location.href) ? !qs('#script-info') && (otherSite == 'greasyfork' || qs('div.width-constraint>section>p>a')) ? location.href = location.href.replace(/\/\/([^.]+\.)?(greasyfork|sleazyfork)\.org/, '//$1' + otherSite + '.org') : false : false : false; }; @@ -695,7 +668,7 @@ function main() { }; } else { inp.checked = cfg[nm]; - if(nm.match(/(autoexpand|sleazyredirct)/gi)) { + if(nm.match(/(autoexpand|sleazyredirect)/gi)) { ael(inp,'change', (e) => { unsaved = true; cfg[nm] = e.target.checked; @@ -716,17 +689,15 @@ function main() { return inp; }, countframe = make('mujs-column'), - gfcountframe = make('magic-userjs', 'counterframe', { - style: 'background: #00b7ff;' - }), - sfcountframe = make('magic-userjs', 'counterframe', { - style: 'background: #ed3f14;' - }), + gfcountframe = make('magic-userjs', 'counterframe'), + sfcountframe = make('magic-userjs', 'counterframe'), gfcounter = make('count-frame','count', { title: 'https://greasyfork.org + https://sleazyfork.org', + style: 'background: #00b7ff;' }), sfcounter = make('count-frame','count', { title: 'https://openuserjs.org', + style: 'background: #ed3f14;' }), buildlist = async (host) => { try { @@ -746,10 +717,12 @@ function main() { code_url: 'about:blank', created_at: Date.now(), code_updated_at: Date.now(), - users: [{ - name: '', - url: '', - }] + users: [ + { + name: '', + url: '', + } + ] }; let sites = [], custom = [], @@ -760,50 +733,90 @@ function main() { if(alang.length > 1) { for(let a of alang) { urls.push(`${i.url}/${a}/scripts/by-site/${host}.json`); - sites.push(MU.fetchURL(`${i.url}/${a}/scripts/by-site/${host}.json`),); + sites.push(MU.fetchURL(`${i.url}/${a}/scripts/by-site/${host}.json?page=1`),); }; - } else { - urls.push(`${i.url}/${clang}/scripts/by-site/${host}.json`); - sites.push(MU.fetchURL(`${i.url}/${clang}/scripts/by-site/${host}.json`),); + continue; }; - } else { - urls.push(`${i.url}/scripts/by-site/${host}.json`); - sites.push(MU.fetchURL(`${i.url}/scripts/by-site/${host}.json`),); - } - }; - if(i.url.match(/(openuserjs.org|github.com)/gi)) { + urls.push(`${i.url}/${clang}/scripts/by-site/${host}.json`); + sites.push(MU.fetchURL(`${i.url}/${clang}/scripts/by-site/${host}.json?page=1`),); + continue; + }; + urls.push(`${i.url}/scripts/by-site/${host}.json`); + sites.push(MU.fetchURL(`${i.url}/scripts/by-site/${host}.json`),); + } else if(i.url.match(/(openuserjs.org|github.com)/gi)) { urls.push(`${i.url}${host}`); custom.push(MU.fetchURL(`${i.url}${host}`,'GET','text'),); }; }; info('Fetching data',host); - let data = await Promise.all(sites).catch((e) => {throw new MUError('Data',e)}); - if(data) { - for(let d of data) { - for(let ujs of d) { - if(ujs.deleted) continue; - if(cfg.filterlang) { - if(alang.length > 1) { - for(let a of alang) { - if(!ujs.locale.includes(a)) continue; - }; - } else if(!ujs.locale.includes(clang)) continue; + if(!isBlank(sites)) { + let hideData = []; + let data = await Promise.all(sites).catch((e) => {throw new MUError('Data',e)}), + joinData = [...new Set([...data[0], ...data[1]])], + filterDeleted = joinData.filter(ujs => !ujs.deleted), + filterLang = cfg.filterlang ? filterDeleted.filter((d) => { + let dlocal = d.locale.split('-')[0] ?? d.locale; + if(alang.length > 1) { + for(let a of alang) { + if(dlocal.includes(a)) { + return true; + }; }; - siteujs.push( - { - url: ujs, - sleazy: false, - }, - ); - sitegfcount++; + } else if(dlocal.includes(clang)) { + return true; }; + hideData.push(d); + return false; + }) : filterDeleted, + finalList = filterLang; + + if(!isBlank(hideData)) { + let hds = []; + for(let h of hideData) { + let txt = await MU.fetchURL(h.code_url,'GET','text'); + let headers = txt.match(/\/\/\s@[\w][\s\S]+/gi) || []; + if(headers.length > 0) { + let regName = new RegExp(`// @name:${clang}\\s+.+`,'gi'), + findName = headers[0].match(regName) || []; + + if(isEmpty(findName)) { + dbg(txt); + continue; + }; + let cReg = new RegExp(`// @name:${clang}\\s+`,'gi'), + cutName = findName[0].replace(cReg, ''); + Object.assign(h, { + name: cutName + }); + + let regDesc = new RegExp(`// @description:${clang}\\s+.+`,'gi'), + findDesc = headers[0].match(regDesc) || []; + if(isEmpty(findDesc)) { + dbg(txt); + continue; + }; + let dReg = new RegExp(`// @description:${clang}\\s+`,'gi'), + cutDesc = findDesc[0].replace(dReg, ''); + Object.assign(h, { + description: cutDesc + }); + hds.push(h); + }; + }; + finalList = [...new Set([...hds, ...filterLang])]; + // dbg(finalList); + + }; + + for(let ujs of finalList) { + siteujs.push( + { + url: ujs, + sleazy: false, + }, + ); + sitegfcount++; }; - // seen.add({ - // host: host, - // data: siteujs, - // gfcount: sitegfcount, - // sfcount: sitesfcount, - // }); for(let ujs of siteujs) { createjs(ujs.url,ujs.sleazy); }; @@ -821,20 +834,22 @@ function main() { if(qs('.col-sm-8 .tr-link',selected)) { for(let i of qsA('.col-sm-8 .tr-link',selected)) { await query('.script-version',i); - let fixurl = qs('.tr-link-a',i).href.replaceAll(doc.location.origin,'https://openuserjs.org'), + let fixurl = qs('.tr-link-a',i).href.replace(new RegExp(doc.location.origin, 'gi'),'https://openuserjs.org'), layout = { name: qs('.tr-link-a',i).textContent, description: qs('p',i).textContent, version: qs('.script-version',i).textContent, url: fixurl, - code_url: `${fixurl.replaceAll('/scripts','/install')}.user.js`, + code_url: `${fixurl.replace(new RegExp('/scripts', 'gi'),'/install')}.user.js`, total_installs: qs('td:nth-child(2) p',i).textContent, created_at: qs('td:nth-child(4) time',i).getAttribute('datetime'), code_updated_at: qs('td:nth-child(4) time',i).getAttribute('datetime'), - users: [{ - name: qs('.inline-block a',i).textContent, - url: qs('.inline-block a',i).href, - }] + users: [ + { + name: qs('.inline-block a',i).textContent, + url: qs('.inline-block a',i).href, + } + ] }; for(const key in template) { if(!Object.hasOwn(layout, key)) { @@ -850,7 +865,7 @@ function main() { if(qs('.repo-list-item',selected)) { for(let r of qsA('.repo-list-item',selected)) { let layout = {}, - fixurl = qs('a',r).href.replaceAll(doc.location.origin,'https://github.com'); + fixurl = qs('a',r).href.replace(new RegExp(doc.location.origin, 'gi'),'https://github.com'); layout = Object.assign(layout, { name: qs('a',r).textContent, description: qs('p.mb-1',r).textContent.trim(), @@ -878,14 +893,15 @@ function main() { for(let g of qsA('div.gist-snippet',selected)) { if(qs('span > a:nth-child(2)',g).textContent.includes('.user.js')) { let layout = {}, - fixurl = qs('span > a:nth-child(2)',g).href.replaceAll(doc.location.origin,'https://gist.github.com'); + fixurl = qs('span > a:nth-child(2)',g).href.replace(new RegExp(doc.location.origin, 'gi'),'https://gist.github.com'); layout = Object.assign(layout, { url: fixurl, code_url: `${fixurl}/raw/${qs('span > a:nth-child(2)',g).textContent}`, + // qs('time-ago.no-wrap',g) created_at: qs('time-ago.no-wrap',g).getAttribute('datetime'), users: [{ name: qs('span > a[data-hovercard-type]',g).textContent, - url: qs('span > a[data-hovercard-type]',g).href.replaceAll(doc.location.origin,'https://gist.github.com'), + url: qs('span > a[data-hovercard-type]',g).href.replace(new RegExp(doc.location.origin, 'gi'),'https://gist.github.com'), }] }); for(let i of qsA('.file-box table tr .blob-code',g)) { @@ -939,7 +955,7 @@ function main() { sfcount: sitesfcount, }); }; - if(isBlank(data) && isBlank(custom)) showError('No available UserJS for this webpage'); + if(isBlank(sites) && isBlank(custom)) showError('No available UserJS for this webpage'); } catch(ex) { showError(ex); }; @@ -999,11 +1015,6 @@ function main() { } }; }; - // if(!isEmpty(site)) { - // if(site !== '*') { - // return buildlist(site); - // }; - // }; return buildlist(site); }, //#region Make Config @@ -1023,7 +1034,7 @@ function main() { }, }); makerow(lang.redirect,'checkbox','sleazyredirect'); - makerow(lang.filter,'checkbox','filter'); + makerow(lang.filter,'checkbox','filterlang'); makerow('Greasy Fork','checkbox','greasyfork'); makerow('Sleazy Fork','checkbox','sleazyfork'); makerow('Open UserJS','checkbox','openuserjs'); @@ -1068,9 +1079,9 @@ function main() { isvalid = true; e.target.setAttribute('style',''); }; - } catch(error) { + } catch(ex) { isvalid = false; - err(error); + err(ex); }; }, }), @@ -1094,7 +1105,7 @@ function main() { rebuild = false; preBuild(); }; - if(/greasyfork\.org/.test(doc.location.hostname) && cfg.sleazyredirct) { + if(/greasyfork\.org/.test(doc.location.hostname) && cfg.sleazyredirect) { let otherSite = /greasyfork\.org/.test(document.location.hostname) ? 'sleazyfork' : 'greasyfork'; qs('span.sign-in-link') ? /scripts\/\d+/.test(document.location.href) ? !qs('#script-info') && (otherSite == 'greasyfork' || qs('div.width-constraint>section>p>a')) ? location.href = location.href.replace(/\/\/([^.]+\.)?(greasyfork|sleazyfork)\.org/, '//$1' + otherSite + '.org') : false : false : false; }; @@ -1103,8 +1114,9 @@ function main() { resetbtn = make('mujs-btn', 'reset', { style: 'margin: auto;', innerHTML: 'Reset', - onclick: async (e) => { + onclick: (e) => { halt(e); + MU.setValue('Config'); unsaved = true; cfg = defcfg; txta.value = JSON.stringify(cfg.blacklist, null, ' '); @@ -1145,11 +1157,11 @@ function main() { btnfullscreen.classList.remove('expanded'); main.classList.remove('expanded'); btnfullscreen.innerHTML = fcopen; - } else { - btnfullscreen.classList.add('expanded'); - main.classList.add('expanded'); - btnfullscreen.innerHTML = fcclose; + return; }; + btnfullscreen.classList.add('expanded'); + main.classList.add('expanded'); + btnfullscreen.innerHTML = fcclose; } }), mainframe = make('magic-userjs','mainframe', { @@ -1339,20 +1351,13 @@ function containerInject() { container.attachShadow({mode: 'open'}); return main(); }; - let ifcss = make('style', 'frame-stylesheet', { - innerHTML: `iframe.mujs-iframe { - position: fixed; - bottom: 1rem; - right: 1rem; - height: 525px; - width: 90%; - margin-left: 1rem; - margin-right: 1rem; - z-index: 100000000000000020 !important; - }`, + ael(ifram, 'load', () => { + ifram.contentDocument.documentElement.classList.add('mujs-iframe'); + ifram.contentDocument.body.classList.add('mujs-iframe'); + main(); }); - ifram.onload = main; - doc.body.append(ifcss,ifram); + // ifram.onload = main; + doc.body.append(ifram); } catch(ex) {handleError(ex)} }; diff --git a/userscript/src/sass/main.scss b/userscript/src/sass/main.scss index 6124c98..cbdcb58 100644 --- a/userscript/src/sass/main.scss +++ b/userscript/src/sass/main.scss @@ -1,7 +1,5 @@ html.webext-page, body.webext-page { - height: 100%; - width: 100%; padding: 0; margin: 0; background: #495060; @@ -47,20 +45,26 @@ magic-userjs * { height: 100% !important; bottom: 0rem !important; }; - &:not(.expanded) { - margin-left: 1rem; - margin-right: 1rem; - right: 1rem; - bottom: 1rem; - &.auto-height { - height: auto; - } + &.webext { + min-width: 50%; + height: 100%; + }; + &:not(.webext) { + position: fixed; + height: 492px; + &:not(.expanded) { + margin-left: 1rem; + margin-right: 1rem; + right: 1rem; + bottom: 1rem; + &.auto-height { + height: auto; + } + }; }; width: 100%; width: -moz-available; width: -webkit-fill-available; - height: 492px; - position: fixed; background: #495060 !important; border: 1px solid rgba(0, 0, 0, 0); border-radius: 10px; @@ -132,7 +136,6 @@ count-frame { font-size: 1em; place-content: space-between; } -body.webext-page, .magicuserjs-body { // overflow-y: scroll; overflow-x: hidden; diff --git a/userscript/tools/userscript.mjs b/userscript/tools/userscript.mjs index 60b2a3d..bf3c05f 100644 --- a/userscript/tools/userscript.mjs +++ b/userscript/tools/userscript.mjs @@ -17,20 +17,12 @@ p = { pub: './userscript/dist/magic-userjs.user.js', }, js_env = process.env.JS_ENV === 'development', -jsonData = JSON.parse(readFileSync('./package.json', 'utf-8')), +jsonData = JSON.parse(readFileSync('./package.json', { encoding: 'utf8' })), // eslint-disable-next-line no-unused-vars buildUserJS = (evt, name) => { - let header = readFileSync('./userscript/src/header.js').toString(), - main_css = readFileSync('./tests/compiled/muserjs.css').toString(), - code = readFileSync('./userscript/src/main.js').toString(), - // renderOut = (outFile, jshead) => { - // let ujs = nano(header, { - // jshead: jshead, - // main_css: main_css, - // code: code, - // }); - // writeFile(outFile, ujs, e => log(e ?? `Build-path: ${outFile}`)); - // }, + let header = readFileSync('./userscript/src/header.js', { encoding: 'utf8' }).toString(), + main_css = readFileSync('./tests/compiled/magicuserjs.css', { encoding: 'utf8' }).toString(), + code = readFileSync('./userscript/src/main.js', { encoding: 'utf8' }).toString(), time = +new Date(), langND = `// @name ${js_env ? `[Dev] ${jsonData.userJS.name}` : jsonData.userJS.name} // @name:zh Magic Userscript+ : 显示当前网站所有可用的UserJS脚本 Jaeger @@ -83,7 +75,6 @@ ${langND} outFile = js_env ? p.dev : p.pub; // Development version : Release version writeFile(outFile, ujs, e => log(e ?? `Build-path: ${outFile}`)); - // renderOut(js_env ? p.dev : p.pub, buildScript); }, watcher = watch(['./userscript/src/'], { delay: 2000, filter: /\.js$/ }); @@ -100,68 +91,3 @@ if(js_env) { } else { buildUserJS(); }; - - -// @exclude /^https:\/\/([^/]*\.)?(\d|pay|bank|money|localhost|authorize|checkout|bill|wallet|router)[0-9]*\./ -// @exclude /^https:\/\/([^/]*\.)?[\S]*\.(gov|org|cart|checkout|login|join|signin|signup|sign-up|password|reset|password_reset)$/ -// @exclude *://paypal.com/* -// @exclude *://*.alipay.com/* -// @exclude *://*bank.*/* -// @exclude *://*perfectmoney.*/* -// @exclude *://*stripe.com/* -// @exclude *://*ica.yandex.com/* -// @exclude *://*authorize.net/* -// @exclude *://*2checkout.com/* -// @exclude *://192.168* -// @exclude *://127.0.0* -// @exclude *://router.*.*/* -// @exclude *://10.0.0* -// @exclude *://*skrill.com/* -// @exclude *://*zalo.me/* -// @exclude *://pay.amazon.*/* -// @exclude *://*.opayo.co.uk/* -// @exclude *://*.payza.org/* -// @exclude *://*.bluesnap.com/* -// @exclude *://securionpay.com/* -// @exclude *://*.unionpayintl.*/* -// @exclude *://*.99bill.com/* -// @exclude *://*.yeepay.com/* -// @exclude *://*payoneer.com/* -// @exclude *://*myetherwallet.com/* -// @exclude *://bitpay.com/* -// @exclude *://*.*/login -// @exclude *://*.*/join -// @exclude *://*.*/signin -// @exclude *://*.*/signup -// @exclude *://*.*/sign-up -// @exclude *://*.*/cart -// @exclude *://*.*.gov/* -// @exclude *://*.*/password_reset -// @exclude *://*.*/checkout* -// @exclude *://*.*/settings/* -// @exclude *://*.*/options/* -// @exclude *://*.*.*/login -// @exclude *://*.*.*/join -// @exclude *://*.*.*/signin -// @exclude *://*.*.*/signup -// @exclude *://*.*.*/sign-up -// @exclude *://*.*.*/cart -// @exclude *://*.*.*/checkout* -// @exclude *://*.*.*/settings/* -// @exclude *://*.*.*/options/* -// @exclude *://*.*.*.gov/* -// @exclude *://*.*.*/password_reset -// @grant GM_getResourceText -// @grant GM.getResourceText -// @grant GM_getValue -// @grant GM.getValue -// @grant GM_setValue -// @grant GM.setValue -// @grant unsafeWindow -// @require ${js_env ? `http://localhost:8080/jquery.slim.min.js` : `https://code.jquery.com/jquery-3.6.1.slim.min.js`} -// @resource uiJs ${js_env ? `http://localhost:8080/ui.js?_=${time}` : `https://cdn.jsdelivr.net/gh/magicoflolis/Userscript-Plus@master/dist/ui.js`} -// @resource gfcount https://greasyfork.org/scripts/by-site.json -// @resource sfcount https://sleazyfork.org/scripts/by-site.json -// @resource sfcount https://sleazyfork.org/scripts/by-site.json -// @require ${js_env ? `https://cdn.jsdelivr.net/gh/jquery/jquery/dist/jquery.slim.min.js` : `https://code.jquery.com/jquery-3.6.1.slim.min.js`} -// @resource uiJs ${js_env ? `http://localhost:8080/ui.js?_=${time}` : `https://cdn.jsdelivr.net/gh/magicoflolis/Userscript-Plus@master/dist/ui.js`}