Skeletons
This commit is contained in:
parent
c3443b5725
commit
8df7431743
|
@ -3,7 +3,7 @@
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
var electron = require("electron");
|
var electron = require("electron");
|
||||||
var src_js_modules_modules, src_js_utils, src_js_api, src_js_event, src_js_core;
|
var src_js_modules_observermodule, src_js_modules_modules, src_js_utils, src_js_api, src_js_plugin, src_js_event, src_js_core;
|
||||||
var _createClass = function () {
|
var _createClass = function () {
|
||||||
function defineProperties(target, props) {
|
function defineProperties(target, props) {
|
||||||
for (var i = 0; i < props.length; i++) {
|
for (var i = 0; i < props.length; i++) {
|
||||||
|
@ -28,10 +28,32 @@
|
||||||
throw new TypeError('Cannot call a class as a function');
|
throw new TypeError('Cannot call a class as a function');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
src_js_modules_modules = function () {
|
src_js_modules_observermodule = function () {
|
||||||
var modules = {};
|
var Observer = function () {
|
||||||
return modules;
|
function Observer() {
|
||||||
|
_classCallCheck(this, Observer);
|
||||||
|
this.mutationObserver = new MutationObserver(this.observe);
|
||||||
|
this.mutationObserver.observe(document, {
|
||||||
|
childList: true,
|
||||||
|
subtree: true
|
||||||
|
});
|
||||||
|
}
|
||||||
|
_createClass(Observer, [{
|
||||||
|
key: 'observe',
|
||||||
|
value: function observe(mutations) {
|
||||||
|
mutations.forEach(function (mutation) {
|
||||||
|
BD.event.emit('raw-mutation', mutation);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}]);
|
||||||
|
return Observer;
|
||||||
|
}();
|
||||||
|
return new Observer();
|
||||||
}();
|
}();
|
||||||
|
src_js_modules_modules = function (observerModule) {
|
||||||
|
var modules = { observerModule: observerModule };
|
||||||
|
return modules;
|
||||||
|
}(src_js_modules_observermodule);
|
||||||
src_js_utils = function () {
|
src_js_utils = function () {
|
||||||
var Utils = function Utils() {
|
var Utils = function Utils() {
|
||||||
_classCallCheck(this, Utils);
|
_classCallCheck(this, Utils);
|
||||||
|
@ -44,39 +66,72 @@
|
||||||
};
|
};
|
||||||
return new Api();
|
return new Api();
|
||||||
}();
|
}();
|
||||||
src_js_event = function () {
|
src_js_plugin = function () {
|
||||||
var eventEmitter = new require('events').EventEmitter;
|
var Plugin = function () {
|
||||||
var event = function () {
|
function Plugin(args) {
|
||||||
function event() {
|
_classCallCheck(this, Plugin);
|
||||||
_classCallCheck(this, event);
|
this.info = args;
|
||||||
}
|
}
|
||||||
_createClass(event, [
|
_createClass(Plugin, [
|
||||||
|
{
|
||||||
|
key: 'author',
|
||||||
|
get: function get() {
|
||||||
|
return this.info.author;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: 'name',
|
||||||
|
get: function get() {
|
||||||
|
return this.info.name;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: 'version',
|
||||||
|
get: function get() {
|
||||||
|
return this.info.version;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]);
|
||||||
|
return Plugin;
|
||||||
|
}();
|
||||||
|
return Plugin;
|
||||||
|
}();
|
||||||
|
src_js_event = function () {
|
||||||
|
var EventEmitter = events.EventEmitter;
|
||||||
|
var Event = function () {
|
||||||
|
function Event() {
|
||||||
|
_classCallCheck(this, Event);
|
||||||
|
this.eventEmitter = new EventEmitter();
|
||||||
|
}
|
||||||
|
_createClass(Event, [
|
||||||
{
|
{
|
||||||
key: 'on',
|
key: 'on',
|
||||||
value: function on(eventName, callback) {
|
value: function on(eventName, callback) {
|
||||||
eventEmitter.on(eventName, callback);
|
this.eventEmitter.on(eventName, callback);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
key: 'emit',
|
key: 'emit',
|
||||||
value: function emit() {
|
value: function emit() {
|
||||||
return 'Not allowed';
|
var _eventEmitter;
|
||||||
|
(_eventEmitter = this.eventEmitter).emit.apply(_eventEmitter, arguments);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
]);
|
]);
|
||||||
return event;
|
return Event;
|
||||||
}();
|
}();
|
||||||
return new event();
|
return new Event();
|
||||||
}();
|
}();
|
||||||
src_js_core = function (modules, utils, api, plugin, event) {
|
src_js_core = function (modules, utils, api, plugin, event) {
|
||||||
var Core = function () {
|
var Core = function () {
|
||||||
function Core(args) {
|
function Core(args) {
|
||||||
_classCallCheck(this, Core);
|
_classCallCheck(this, Core);
|
||||||
|
console.log(event);
|
||||||
|
this.event = event;
|
||||||
|
this.modules = modules;
|
||||||
this.beta = true;
|
this.beta = true;
|
||||||
this.alpha = true;
|
this.alpha = true;
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
this.event = event;
|
|
||||||
this.eventEmitter = event.eventEmitter;
|
|
||||||
}
|
}
|
||||||
_createClass(Core, [
|
_createClass(Core, [
|
||||||
{
|
{
|
||||||
|
@ -103,8 +158,8 @@
|
||||||
window.$B = function (s) {
|
window.$B = function (s) {
|
||||||
return $('[data-bd=' + s);
|
return $('[data-bd=' + s);
|
||||||
};
|
};
|
||||||
var BD = new Core();
|
window.BD = new Core();
|
||||||
BD.init();
|
BD.init();
|
||||||
}(src_js_modules_modules, src_js_utils, src_js_api, src_js_event);
|
}(src_js_modules_modules, src_js_utils, src_js_api, src_js_plugin, src_js_event);
|
||||||
|
|
||||||
}());
|
}());
|
|
@ -38,7 +38,7 @@ const _resources = {
|
||||||
"jQuery": {
|
"jQuery": {
|
||||||
"path": "vendor",
|
"path": "vendor",
|
||||||
"filename": "jquery-2.2.4.min.js",
|
"filename": "jquery-2.2.4.min.js",
|
||||||
"var": "window.BD.$ = window.BD.jQuery"
|
"var": "window.$ = window.jQuery"
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -13,17 +13,19 @@ define([
|
||||||
"./modules/modules",
|
"./modules/modules",
|
||||||
"./utils",
|
"./utils",
|
||||||
"./api",
|
"./api",
|
||||||
|
"./plugin",
|
||||||
"./event"
|
"./event"
|
||||||
], (modules, utils, api, plugin, event) => {
|
], (modules, utils, api, plugin, event) => {
|
||||||
|
|
||||||
class Core {
|
class Core {
|
||||||
|
|
||||||
constructor(args) {
|
constructor(args) {
|
||||||
|
console.log(event);
|
||||||
|
this.event = event;
|
||||||
|
this.modules = modules;
|
||||||
this.beta = true;
|
this.beta = true;
|
||||||
this.alpha = true;
|
this.alpha = true;
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
this.event = event;
|
|
||||||
this.eventEmitter = event.eventEmitter;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
init() {
|
init() {
|
||||||
|
@ -42,7 +44,7 @@ define([
|
||||||
|
|
||||||
window.$B = s => { return $(`[data-bd=${s}`); };
|
window.$B = s => { return $(`[data-bd=${s}`); };
|
||||||
|
|
||||||
const BD = new Core();
|
window.BD = new Core();
|
||||||
BD.init();
|
BD.init();
|
||||||
|
|
||||||
});
|
});
|
|
@ -11,19 +11,23 @@
|
||||||
|
|
||||||
define(() => {
|
define(() => {
|
||||||
|
|
||||||
const eventEmitter = new require('events').EventEmitter;
|
const EventEmitter = new require('events').EventEmitter;
|
||||||
|
|
||||||
class event {
|
class Event {
|
||||||
|
|
||||||
on(eventName, callback) {
|
constructor() {
|
||||||
eventEmitter.on(eventName, callback);
|
this.eventEmitter = new EventEmitter;
|
||||||
}
|
}
|
||||||
|
|
||||||
emit() {
|
on(eventName, callback) {
|
||||||
return "Not allowed";
|
this.eventEmitter.on(eventName, callback);
|
||||||
|
}
|
||||||
|
|
||||||
|
emit(...args) {
|
||||||
|
this.eventEmitter.emit(...args);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return new event();
|
return new Event();
|
||||||
});
|
});
|
|
@ -8,9 +8,13 @@
|
||||||
* License: MIT
|
* License: MIT
|
||||||
*/
|
*/
|
||||||
|
|
||||||
define([], () => {
|
define([
|
||||||
|
"./observermodule"
|
||||||
|
], (observerModule) => {
|
||||||
|
|
||||||
var modules = {};
|
const modules = {
|
||||||
|
observerModule: observerModule
|
||||||
|
};
|
||||||
|
|
||||||
return modules;
|
return modules;
|
||||||
});
|
});
|
|
@ -0,0 +1,34 @@
|
||||||
|
/* BetterDiscordApp Client Observer
|
||||||
|
* Version: 2:1.0
|
||||||
|
* Author: Jiiks | https://jiiks.net
|
||||||
|
* Date: 31/10/2016
|
||||||
|
* Last Update: 31/10/2016
|
||||||
|
* Github: https://github.com/Jiiks/BetterDiscordApp
|
||||||
|
* Git: https://github.com/Jiiks/BetterDiscordApp.git
|
||||||
|
* License: MIT
|
||||||
|
*/
|
||||||
|
|
||||||
|
define([], () => {
|
||||||
|
|
||||||
|
class Observer {
|
||||||
|
|
||||||
|
constructor() {
|
||||||
|
this.mutationObserver = new MutationObserver(this.observe);
|
||||||
|
this.mutationObserver.observe(document, {
|
||||||
|
childList: true,
|
||||||
|
subtree: true
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
observe(mutations) {
|
||||||
|
|
||||||
|
mutations.forEach(mutation => {
|
||||||
|
BD.event.emit("raw-mutation", mutation);
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return new Observer();
|
||||||
|
});
|
Loading…
Reference in New Issue