-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
dfbeb8e
commit 138fb2b
Showing
14 changed files
with
2,925 additions
and
1,126 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
[*] | ||
end_of_line = lf | ||
insert_final_newline = true | ||
indent_size = 2 | ||
indent_style = space |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"files.exclude": { | ||
"**/.git": true, | ||
"**/.svn": true, | ||
"**/.hg": true, | ||
"**/CVS": true, | ||
"**/.DS_Store": true, | ||
"node_modules":true | ||
} | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,78 +1,91 @@ | ||
const gulp = require('gulp'); | ||
const _$ = require('gulp-load-plugins')(); | ||
const rsequence = require('run-sequence'); | ||
const del = require('del'); | ||
const gulp = require('gulp') | ||
const _$ = require('gulp-load-plugins')() | ||
const del = require('del') | ||
const manifest = require('./src/chrome/manifest.json') | ||
|
||
const srcJs = ['src/**/*.js', '!src/vendor/*.js']; | ||
const srcCs = ['src/stylus/*.styl']; | ||
const srcJs = ['src/**/*.js', '!src/vendor/*.js'] | ||
const srcCs = ['src/stylus/*.styl'] | ||
|
||
gulp.task('clean', function(cb) { | ||
return del('./tmp/**/*'); | ||
cb(err); | ||
}); | ||
function clean (cb) { | ||
del('./tmp/**/*') | ||
cb() | ||
} | ||
|
||
gulp.task('build', ['clean'], function() { | ||
rsequence('chrome') | ||
}) | ||
const chromeFiles = gulp.series(chromeHtml, chromeJs, chromeIcons, chromeCss, chromeVendor, chromeJson) | ||
|
||
gulp.task('build', gulp.series(clean, chromeFiles)) | ||
|
||
gulp.task('dist', ['chrome:zip']); | ||
gulp.task('dist', gulp.series(chromeFiles, chromeZip)) | ||
|
||
gulp.task('chrome', ['chrome:html', 'chrome:js', 'chrome:icons', 'chrome:css', 'chrome:vendor'], function() { | ||
return gulp.src('./src/chrome/*.json') | ||
.pipe(gulp.dest('./tmp/chrome')); | ||
}); | ||
function chromeJson (cb) { | ||
gulp.src('./src/chrome/*.json') | ||
.pipe(gulp.dest('./tmp/chrome')) | ||
cb() | ||
} | ||
|
||
gulp.task('chrome:html', function(cb) { | ||
return universalFile('chrome', 'html'); | ||
cb(err); | ||
}); | ||
function chromeHtml (cb) { | ||
universalFile('chrome', 'html', cb) | ||
} | ||
|
||
gulp.task('chrome:js', function(cb) { | ||
return gulp.src(srcJs) | ||
.pipe(_$.jsmin()) | ||
.pipe(_$.rename(function(path) { | ||
if (path.dirname === 'chrome') { | ||
path.dirname = './' | ||
} | ||
path.basename += '.min'; | ||
})) | ||
.pipe(gulp.dest('tmp/chrome')) | ||
cb(err); | ||
}); | ||
exports.js = chromeJs | ||
function chromeJs (cb) { | ||
gulp.src(srcJs) | ||
.pipe(_$.jsmin()) | ||
.pipe(_$.rename(function (path) { | ||
if (path.dirname === 'chrome') { | ||
path.dirname = './' | ||
} | ||
path.basename += '.min' | ||
})) | ||
.pipe(gulp.dest('tmp/chrome')) | ||
.on('error', function (err) { | ||
console.error('Js: ' + err.toString()) | ||
}) | ||
cb() | ||
} | ||
|
||
gulp.task('chrome:icons', function(cb) { | ||
return universalFile('chrome', 'icons'); | ||
cb(err); | ||
}); | ||
function chromeIcons (cb) { | ||
universalFile('chrome', 'icons', cb) | ||
} | ||
|
||
gulp.task('chrome:css', function(cb) { | ||
return gulp.src(srcCs) | ||
.pipe(_$.stylus()) | ||
.pipe(_$.csso()) | ||
.pipe(gulp.dest('src/css/')) | ||
.pipe(_$.rename({dirname: 'css', suffix: '.min'})) | ||
.pipe(gulp.dest('tmp/chrome')) | ||
cb(err); | ||
}); | ||
function chromeCss (cb) { | ||
gulp.src(srcCs) | ||
.pipe(_$.stylus()) | ||
.pipe(_$.csso()) | ||
.on('error', err => { | ||
console.error(err.toString()) | ||
}) | ||
.pipe(_$.rename({ dirname: 'css', suffix: '.min' })) | ||
.pipe(gulp.dest('tmp/chrome')) | ||
.on('error', err => { | ||
console.error(err.toString()) | ||
}) | ||
cb() | ||
} | ||
|
||
gulp.task('chrome:vendor', function(cb) { | ||
return universalFile('chrome', 'vendor'); | ||
cb(err); | ||
}); | ||
function chromeVendor (cb) { | ||
universalFile('chrome', 'vendor', cb) | ||
} | ||
|
||
gulp.task('chrome:zip', function() { | ||
return gulp.src('./tmp/chrome/**/*') | ||
.pipe(_$.zip('chrome.zip')) | ||
.pipe(gulp.dest('./dist')); | ||
}); | ||
function chromeZip (cb) { | ||
gulp.src('./tmp/chrome/**/*') | ||
.pipe(_$.zip(`whatsbot_${manifest.version}.zip`)) | ||
.pipe(gulp.dest('./dist')) | ||
cb() | ||
} | ||
|
||
gulp.task('watch', function (cb) { | ||
gulp.watch(srcJs, gulp.series(chromeJs)) | ||
gulp.watch(srcCs, gulp.series(chromeCss)) | ||
gulp.watch(['src/chrome/manifest.json'], gulp.series(chromeJson)) | ||
gulp.watch(['src/html/*.html'], gulp.series(chromeHtml)) | ||
cb() | ||
}) | ||
|
||
gulp.task('watch', function() { | ||
gulp.watch(srcJs, ['build']); | ||
gulp.watch(srcCs, ['build']) | ||
gulp.watch(['src/chrome/manifest.json', 'src/html/*.html'], ['build']) | ||
}); | ||
function universalFile (folderName, files, cb) { | ||
gulp.src('./src/' + files + '/*') | ||
.pipe(gulp.dest('./tmp/' + folderName + '/' + files)) | ||
cb() | ||
} | ||
|
||
function universalFile(folderName, files) { | ||
return gulp.src('./src/' + files + '/*') | ||
.pipe(gulp.dest('./tmp/' + folderName + '/' + files)); | ||
} | ||
exports.default = gulp.series('watch') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,24 @@ | ||
{ | ||
"name": "WhatsBot", | ||
"name": "whatsbot", | ||
"version": "0.1.0", | ||
"description": "Automatizando el envio de mensajes dentro del cliente web de whatsapp", | ||
"main": "\"\"", | ||
"repository": "https://github.com/edgarvaguencia/whatsBot.git", | ||
"author": "Edgar Valencia <isc.edgarvalencia@gmail.com>", | ||
"license": "MIT", | ||
"scripts": { | ||
"watch": "yarn gulp", | ||
"build": "yarn gulp build", | ||
"dist": "yarn gulp dist" | ||
}, | ||
"devDependencies": { | ||
"del": "^2.2.2", | ||
"gulp": "^3.9.1", | ||
"gulp-csso": "^2.0.0", | ||
"del": "5.1.0", | ||
"gulp": "4.0.2", | ||
"gulp-csso": "3.0.1", | ||
"gulp-jsmin": "^0.1.5", | ||
"gulp-load-plugins": "^1.4.0", | ||
"gulp-rename": "^1.2.2", | ||
"gulp-stylus": "^2.6.0", | ||
"gulp-zip": "^3.2.0", | ||
"run-sequence": "^1.2.2" | ||
"gulp-load-plugins": "2.0.1", | ||
"gulp-rename": "1.4.0", | ||
"gulp-stylus": "2.7.0", | ||
"gulp-zip": "5.0.1" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,14 @@ | ||
window.WhBoCo = (function(){ | ||
window.WhBoCo = (function () { | ||
var _config = { | ||
contacts: {}, | ||
chats: {} | ||
} | ||
|
||
var _config = { | ||
contacts : {}, | ||
chats: {} | ||
} | ||
function _returnConfig () { | ||
return _config | ||
} | ||
|
||
function _returnConfig() { | ||
return _config; | ||
} | ||
|
||
return { | ||
get: _returnConfig | ||
} | ||
})(); | ||
return { | ||
get: _returnConfig | ||
} | ||
})() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,55 +1,66 @@ | ||
var _gaq = _gaq || []; | ||
(function() { | ||
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true; | ||
ga.src = 'https://ssl.google-analytics.com/ga.js'; | ||
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s); | ||
var _gaq = window['_gaq'] !== undefined ? window['_gaq'] : []; | ||
(function () { | ||
var ga = document.createElement('script') | ||
ga.type = 'text/javascript' | ||
ga.async = true | ||
ga.src = 'https://ssl.google-analytics.com/ga.js' | ||
var s = document.getElementsByTagName('script')[0] | ||
s.parentNode.insertBefore(ga, s) | ||
})() | ||
WhBo = (function() { | ||
const WhBo = (function () { | ||
// **************************************************************************** | ||
// * Datos compartidos * | ||
// **************************************************************************** | ||
const url_whats = 'https://web.whatsapp.com'; | ||
const urlWhats = 'https://web.whatsapp.com' | ||
|
||
function getWhatsTab(callback) { | ||
var url_search_ = url_whats + '/'; | ||
chrome.tabs.query({currentWindow: !0, url: url_search_}, function(tabs) { | ||
tabs.length == 0 ? (chrome.tabs.create({url: url_whats}, callback)) : chrome.tabs.update(tabs[0].id, {selected: true}, callback); | ||
}); | ||
} | ||
function getWhatsTab (callback) { | ||
let urlSearch_ = urlWhats + '/' | ||
window['chrome'].tabs.query({ currentWindow: !0, url: urlSearch_ }, function (tabs) { | ||
tabs.length === 0 ? (window['chrome'].tabs.create({ url: urlWhats }, callback)) : window['chrome'].tabs.update(tabs[0].id, { selected: true }, callback) | ||
}) | ||
} | ||
|
||
function _track(obj) { | ||
_gaq.push(['_setAccount', 'UA-76663200-3']); | ||
_gaq.push(['_trackEvent', obj.info, obj.type]); | ||
} | ||
function _track (obj) { | ||
_gaq.push(['_setAccount', 'UA-76663200-3']) | ||
_gaq.push(['_trackEvent', obj.info, obj.type]) | ||
} | ||
|
||
function _page() { | ||
_gaq.push(['_setAccount', 'UA-76663200-3']); | ||
_gaq.push(['_trackPageview']); | ||
} | ||
function _page () { | ||
_gaq.push(['_setAccount', 'UA-76663200-3']) | ||
_gaq.push(['_trackPageview']) | ||
} | ||
|
||
// **************************************************************************** | ||
// * Datos y funciones genericas * | ||
// **************************************************************************** | ||
manifest = chrome.runtime.getManifest() | ||
|
||
chrome.runtime.onInstalled.addListener(function(detail) { | ||
detail.reason === 'install' ? (_track({info: manifest.version, type: 'install'}), closeWhatsTab()) : detail.reason === 'update' && _track({info: manifest.version, type: 'update'}) | ||
}); | ||
|
||
function closeWhatsTab () { | ||
var url_search_ = url_whats + '/*' | ||
chrome.tabs.query({currentWindow: !0, url: url_search_}, function(tabs) { | ||
if (tabs.length != 0) { | ||
chrome.tabs.remove(tabs[0].id); | ||
} | ||
}); | ||
} | ||
|
||
return { | ||
whatsTab: getWhatsTab, | ||
tracking: _track, | ||
trackPage: _page, | ||
} | ||
})(); | ||
|
||
WhBo.trackPage(); | ||
// **************************************************************************** | ||
// * Datos y funciones genericas * | ||
// **************************************************************************** | ||
const manifest = window['chrome'].runtime.getManifest() | ||
|
||
window['chrome'].runtime.onInstalled.addListener(function (detail) { | ||
switch (detail) { | ||
case 'install': | ||
_track({ info: manifest.version, type: 'install' }) | ||
closeWhatsTab() | ||
break | ||
case 'update': | ||
_track({ info: manifest.version, type: 'update' }) | ||
break | ||
} | ||
}) | ||
|
||
function closeWhatsTab () { | ||
let urlSearch = urlWhats + '/*' | ||
window['chrome'].tabs.query({ currentWindow: !0, url: urlSearch }, function (tabs) { | ||
if (tabs.length !== 0) { | ||
window['chrome'].tabs.remove(tabs[0].id) | ||
} | ||
}) | ||
} | ||
|
||
return { | ||
whatsTab: getWhatsTab, | ||
tracking: _track, | ||
trackPage: _page | ||
} | ||
})() | ||
|
||
WhBo.trackPage() |
Oops, something went wrong.