Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class People {
- constructor () {
- let stored = JSON.parse(localStorage.getItem('people'));
- stored = typeof stored === 'object' ? true : this.init();
- }
- init () {
- let empty = [];
- localStorage.setItem('people', JSON.stringify(empty));
- }
- load () {
- return JSON.parse(localStorage.getItem('people'));
- }
- save (person) {
- let stored = this.load();
- stored.unshift(person);
- localStorage.setItem('people', JSON.stringify(stored));
- }
- view () {
- console.table(this.load());
- }
- }
- class Profile {
- constructor() {
- const elementDescription = document.querySelector('.profile-section__txt-line') === null ? document.createElement("p.profile-section__txt-line") : document.querySelector('.profile-section__txt-line');
- const number = elementDescription.innerHTML === null ? '' : elementDescription.innerHTML.match(/\d+/g);
- this.description = elementDescription === null ? '' : elementDescription.innerHTML;
- this.number = number === null ? false : parseInt(number.join(''));
- this.words_not_allowed = [''];
- }
- rateProfile () {
- if (this.checkDescription() === true) {
- let person = new People();
- person.save(this);
- this.accept();
- return true;
- } else {
- this.reject();
- return false;
- }
- }
- checkDescription() {
- const description = this.description;
- const result = this.words_not_allowed.map(word => description.includes(word) ? true : false );
- return result.includes(true) ? false : true;
- }
- accept() {
- document.querySelector('.profile-action--yes').click();
- }
- reject() {
- document.querySelector('.profile-action--no').click();
- }
- }
- class Bot {
- constructor () {
- this.enabled = false;
- this.operation = null;
- }
- checkMatch () {
- const profile = new Profile();
- profile.rateProfile();
- }
- toggle () {
- if (this.enabled === false) {
- this.operation = setInterval(this.checkMatch, 250);
- this.enabled = true;
- } else {
- const people = new People();
- const stored = people.load();
- clearInterval(this.operation);
- this.enabled = false;
- alert(`Demos ${stored.length} like no total.`);
- }
- }
- }
- const bot = new Bot();
- document.body.addEventListener('mousedown', function (e) {
- if (e.which === 2) {
- e.preventDefault();
- bot.toggle();
- }
- });
Add Comment
Please, Sign In to add comment