// ==UserScript== // @name BugMeNot Everywhere // @namespace https://greasyfork.org/users/37096/ // @homepage https://greasyfork.org/scripts/35957/ // @supportURL https://greasyfork.org/scripts/35957/feedback // @version 1.1.1 // @description Add a list of login accounts from BugMeNot ( bugmenot.com ) on any website when focusing on username input // @author Hồng Minh Tâm // @icon http://bugmenot.com/favicon.ico // @include * // @connect bugmenot.com // @grant GM_addStyle // @grant GM_xmlhttpRequest // @license GNU GPLv3 // @downloadURL none // ==/UserScript== (function () { 'use strict'; const icons = { username: '', password: '', } GM_addStyle([ '.bmn-list { display:none; list-style: none; border: 1px solid #ccc; padding: 0; margin: 0; background-color: #fff; position: fixed; cursor: default; z-index: 9999999999; box-sizing: border-box; overflow: auto; text-align: left; }', '.bmn-list.show { display:block; }', '.bmn-list .bmn-row { position: relative; margin: 0 5px 5px 5px; display: -ms-flexbox; display: -webkit-flex; display: flex; }', '.bmn-list .bmn-row:last-child { margin-bottom: 0; }', '.bmn-list .bmn-col { position: relative; display: -ms-flexbox; display: -webkit-flex; display: flex; -webkit-flex-direction: column; -ms-flex-direction: column; flex-direction: column; }', '.bmn-list .bmn-full { -webkit-flex: 1 0 auto; -ms-flex: 1 0 auto; flex: 1 0 auto; }', '.bmn-list .bmn-align-items-center { -webkit-align-items: center; -ms-flex-align: center; align-items: center; }', '.bmn-list .bmn-align-self-center { -webkit-align-self: center; -ms-flex-item-align: center; align-self: center; }', '.bmn-list .bmn-justify-content-center { -webkit-justify-content: center; -ms-flex-pack: center; justify-content: center; }', '.bmn-list .bmn-item { position: relative; padding: 5px 2px 5px 7px; margin: 0; cursor: pointer; border-bottom: 1px solid rgba(0,0,0,.125); color: #495057; }', '.bmn-list .bmn-item:last-child { border-bottom: 0; }', '.bmn-list .bmn-item:hover { background-color: #f8f9fa; }', '.bmn-list .bmn-item:before { position: absolute; content: ""; width: 5px; top: 0; left: 0; bottom: 0; background-color: #f7704f; }', '.bmn-list .bmn-item .bmn-icon { width: 32px; height: 32px; padding: 5px; background-color: #e9ecef; border: 1px solid #ced4da; }', '.bmn-list .bmn-item .bmn-username { margin-left: 10px; font-weight: 700; }', '.bmn-list .bmn-item .bmn-password { margin-left: 10px; color: #666; }', '.bmn-list .bmn-item .bmn-success { display: inline-block; font-weight: 700; }', '.bmn-list .bmn-item.bmn-success-100 .bmn-success { color: rgb(0,198,0); }', '.bmn-list .bmn-item.bmn-success-100:before { background-color: rgb(0,198,0); }', '.bmn-list .bmn-item.bmn-success-90 .bmn-success { color: rgb(50,180,0); }', '.bmn-list .bmn-item.bmn-success-90:before { background-color: rgb(50,180,0); }', '.bmn-list .bmn-item.bmn-success-80 .bmn-success { color: rgb(99,164,0); }', '.bmn-list .bmn-item.bmn-success-80:before { background-color: rgb(99,164,0); }', '.bmn-list .bmn-item.bmn-success-70 .bmn-success { color: rgb(149,146,0); }', '.bmn-list .bmn-item.bmn-success-70:before { background-color: rgb(149,146,0); }', '.bmn-list .bmn-item.bmn-success-60 .bmn-success { color: rgb(199,129,0); }', '.bmn-list .bmn-item.bmn-success-60:before { background-color: rgb(199,129,0); }', '.bmn-list .bmn-item.bmn-success-50 .bmn-success { color: rgb(247,112,0); }', '.bmn-list .bmn-item.bmn-success-50:before { background-color: rgb(247,112,0); }', '.bmn-list .bmn-item.bmn-success-40 .bmn-success { color: rgb(247,90,0); }', '.bmn-list .bmn-item.bmn-success-40:before { background-color: rgb(247,90,0); }', '.bmn-list .bmn-item.bmn-success-30 .bmn-success { color: rgb(247,67,0); }', '.bmn-list .bmn-item.bmn-success-30:before { background-color: rgb(247,67,0); }', '.bmn-list .bmn-item.bmn-success-20 .bmn-success { color: rgb(247,45,0); }', '.bmn-list .bmn-item.bmn-success-20:before { background-color: rgb(247,45,0); }', '.bmn-list .bmn-item.bmn-success-10 .bmn-success { color: rgb(247,22,0); }', '.bmn-list .bmn-item.bmn-success-10:before { background-color: rgb(247,22,0); }', '.bmn-list .bmn-item .bmn-vote { display: inline-block; margin-left: 16px; float: right; }', '.bmn-list .bmn-no-logins-found { padding: 5px 10px; margin: 0; cursor: default; text-align: center; background-color: #a90000; color: #fff; }', ].join('')); Object.defineProperty(String.prototype, 'toDOM', { value: function (isFull) { var parser = new DOMParser(), dom = parser.parseFromString(this, 'text/html'); return isFull ? dom : dom.body.childNodes[0]; }, enumerable: false }); function setValueInput(input, value, isInputSimulate) { var setValue = Object.getOwnPropertyDescriptor(window.HTMLInputElement.prototype, 'value').set; setValue.call(input, value); if (isInputSimulate) { var e = new Event('input', { bubbles: true }); input.dispatchEvent(e); } } function getOffset(element) { var elementRect = element.getBoundingClientRect(); return { left: elementRect.left, right: elementRect.right, top: elementRect.top, bottom: elementRect.bottom, }; } function handleEvent(func, data) { return function (event) { func.bind(this)(event, data); }; } var accounts = []; var inputUsernameCurrentEl, inputPasswordCurrentEl; var minHeightListBMN = 100; GM_xmlhttpRequest({ method: 'GET', url: 'http://bugmenot.com/view/' + location.hostname, headers: { 'Content-Type': 'application/x-www-form-urlencoded' }, onload: function (response) { var bmnEl = response.responseText.toDOM(true); var accountEls = bmnEl.getElementsByClassName('account'); for (var i = 0; i < accountEls.length; i++) { var accountEl = accountEls[i]; var infoEl = accountEl.getElementsByTagName('kbd'); var statsEl = accountEl.getElementsByClassName('stats')[1].getElementsByTagName('li'); var account = { username: infoEl[0].innerHTML || '', password: infoEl[1].innerHTML || '', success: parseInt(statsEl[0].innerHTML.match(/\d+(?=%)/)[0]), vote: parseInt(statsEl[1].innerHTML.match(/\d+(?=\svotes)/)[0]), time: statsEl[2].innerHTML }; accounts.push(account); } init(); }, onerror: function (response) { } }); function init() { var listBMNEl = document.createElement('ul'); listBMNEl.classList.add('bmn-list'); document.body.appendChild(listBMNEl); function showListBMNEl() { listBMNEl.classList.add('show'); } function hideListBMNEl() { listBMNEl.classList.remove('show'); } if (accounts.length) { accounts.forEach(function (account, index) { var itemBMNEl = document.createElement('li'); itemBMNEl.classList.add('bmn-item'); itemBMNEl.classList.add(getClassSuccess(account.success)); var itemBMNElHTML = [ '