Skip to content

Commit

Permalink
updated userscript, fixed null error, better performance
Browse files Browse the repository at this point in the history
  • Loading branch information
Venipa committed Mar 16, 2020
1 parent f81c81b commit 236536d
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 17 deletions.
10 changes: 5 additions & 5 deletions CoubDownload-Bridge-Userscript/dist/app.js

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

3 changes: 3 additions & 0 deletions CoubDownload-Bridge-Userscript/src/app.dev.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
global.dev = true;

require('./app');
8 changes: 5 additions & 3 deletions CoubDownload-Bridge-Userscript/src/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@
};
var log = {
debug: function(msg, ...params) {
if (!dev) {
return;
}
console.log('[coub-bridge|debug] ', msg, params);
},
tag: function(tag, msg, ...params) {
Expand All @@ -72,9 +75,9 @@
.filter(x => x.querySelectorAll)
.forEach(x => {
var controls = x.querySelector('.description__controls');
if (controls && controls.querySelectorAll) {
var coubId;
if (controls && controls.querySelectorAll && x && (coubId = x.getAttribute('data-permalink'))) {
if (controls.querySelectorAll('#' + buttonId).length === 0) {
let coubId = x.getAttribute('data-permalink');
let downloadBtn = downloadButton();
downloadBtn.href = 'coubdl-bridge://' + coubId;
downloadBtn.innerText = 'Download';
Expand All @@ -86,7 +89,6 @@
controls.prepend(grp);
}
if (controls.querySelectorAll('#' + buttonAudioId).length === 0) {
let coubId = x.getAttribute('data-permalink');
let downloadBtn = downloadButton();
downloadBtn.id = buttonAudioId;
downloadBtn.innerText = 'Audio';
Expand Down
3 changes: 3 additions & 0 deletions CoubDownload-Bridge-Userscript/src/app.prod.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
global.dev = false;

require('./app');
4 changes: 2 additions & 2 deletions CoubDownload-Bridge-Userscript/src/banner.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// ==UserScript==
// @name Coub-Bridge
// @namespace https://venipa.net
// @version 0.2.0
// @description try to take over the world!
// @version 0.2.1
// @description Bridge between the desktop and webbrowser to download and merge video & audio from coub
// @author Venipa
// @match https://*.coub.com/*
// @match https://coub.com/*
Expand Down
17 changes: 10 additions & 7 deletions CoubDownload-Bridge-Userscript/webpack.mix.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
let mix = require('laravel-mix');
const { BannerPlugin } = require('webpack');
const { readFileSync } = require('fs');
let mix = require("laravel-mix");
const { BannerPlugin } = require("webpack");
const { readFileSync } = require("fs");
/*
|--------------------------------------------------------------------------
| Mix Asset Management
Expand All @@ -11,11 +11,11 @@ const { readFileSync } = require('fs');
| file for your application, as well as bundling up your JS files.
|
*/
mix.setPublicPath('dist');
mix.setPublicPath("dist");
mix.webpackConfig({
plugins: [
new BannerPlugin({
banner: readFileSync('./src/banner.js').toString(),
banner: readFileSync("./src/banner.js").toString(),
raw: true
})
]
Expand All @@ -34,12 +34,15 @@ mix.options({
return file;
},
banner: () => {
return readFileSync('./src/banner.js').toString();
return readFileSync("./src/banner.js").toString();
}
}
}
});
mix.js('src/app.js', 'dist/');
mix.js(
process.env.NODE_ENV === "production" ? "src/app.prod.js" : "src/app.dev.js",
"dist/app.js"
);

// Full API
// mix.js(src, output);
Expand Down

0 comments on commit 236536d

Please sign in to comment.