Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- // ==UserScript==
- // @name addressfinder
- // @namespace amDOGE
- // @include http*://boards.4chan.org/*
- // @version 1
- // @grant none
- // @run-at document-start
- // ==/UserScript==
- */
- (function() {
- var $, $$, Main, c, d, tipSize, wait, walletType,
- __slice = [].slice;
- d = document;
- c = console;
- $ = function(selector, root) {
- if (root == null) {
- root = d.body;
- }
- return root.querySelector(selector);
- };
- $$ = function(selector, root) {
- if (root == null) {
- root = d.body;
- }
- return __slice.call(root.querySelectorAll(selector));
- };
- /*
- Use walletType to configure which wallet(s) to search for. Bitcoin (1), Dogecoin (D), Litecoin (L) and PandaCoin (P) are added by default.
- */
- walletType = '1|D|L|P';
- /*
- Use tipSize to set a default amount to tip, ie. P: '1500'
- */
- tipSize = {
- 1: '',
- D: '',
- L: '',
- P: ''
- };
- /*
- GET post size can be configured with x
- */
- Main = {
- init: function() {
- this.catchAll = RegExp("(" + walletType + ")[A-Za-z0-9]{33}");
- this.pastebin = /pastebin\.com\/(?!u\/)(?:raw.php\?i=)?([a-zA-Z0-9]+)/i;
- this.thread = $('.thread');
- this.nodes = $$('.postContainer', this.thread);
- this.wallets = {};
- Main.findNodes(this.nodes);
- return Main.observe();
- },
- findNodes: function(nodes) {
- var email, emailText, href, key, node, searchable, _i, _len;
- for (_i = 0, _len = nodes.length; _i < _len; _i++) {
- node = nodes[_i];
- searchable = [];
- if (email = $('.useremail', node)) {
- key = 'email';
- href = email.href.trim();
- emailText = decodeURIComponent(href) || href;
- searchable.push({
- key: key,
- node: node,
- email: email,
- emailText: emailText
- });
- }
- Main.node(searchable);
- }
- },
- node: function(searchable) {
- var field, handler, id, isPastebin, key, node, text, _i, _len, _ref;
- if (!searchable[0]) {
- return;
- }
- for (_i = 0, _len = searchable.length; _i < _len; _i++) {
- field = searchable[_i];
- key = field.key, node = field.node;
- text = field[key + 'Text'];
- id = node.id.slice(2);
- if (isPastebin = (_ref = text.match(Main.pastebin)) != null ? _ref[1] : void 0) {
- Main.getPastebin(isPastebin, id);
- handler = isPastebin;
- } else {
- if (!(handler = Main.parseHandler(text))) {
- continue;
- }
- }
- Main.assign(id, handler);
- node = field[key];
- node.parentNode.parentNode.parentNode.addEventListener('mouseover', Main.swapHandler);
- }
- },
- parseWalletType: function(short) {
- var coinType;
- coinType = (function() {
- switch (short) {
- case '1':
- return 'bit';
- case 'D':
- return 'doge';
- case 'L':
- return 'lite';
- case 'P':
- return 'panda';
- }
- })();
- return coinType + 'coin';
- },
- parseHandler: function(text) {
- var address, amount, handler, short, walletAddress;
- if (!(address = text.match(this.catchAll))) {
- return;
- }
- walletAddress = address[0], short = address[1];
- walletType = this.parseWalletType(short);
- handler = "" + walletType + ":" + walletAddress;
- if (amount = tipSize[short]) {
- handler += "?amount=" + amount;
- }
- return handler;
- },
- getPastebin: function(paste, id) {
- var url, xhr;
- url = "http://pastebin.com/raw.php?i=" + paste;
- xhr = new XMLHttpRequest();
- xhr.open('get', url, true);
- id = id;
- xhr.onloadend = function() {
- var _ref;
- if ((_ref = this.status) !== 200 && _ref !== 304) {
- return;
- }
- return Main.assign(id, Main.parseHandler(this.response));
- };
- return xhr.send(null);
- },
- assign: function(id, handler) {
- return this.wallets[id] = handler;
- },
- swapHandler: function(e) {
- var node, wallet;
- wallet = Main.wallets[this.id.slice(1)];
- node = $('.useremail', this);
- node.href = wallet;
- return this.removeEventListener('mouseover', Main.swapHandler);
- },
- observe: function() {
- var config, observer;
- Main.observer = observer = new MutationObserver(function(mutations) {
- var mutation, node, _i, _len, _ref;
- for (_i = 0, _len = mutations.length; _i < _len; _i++) {
- mutation = mutations[_i];
- if ((node = (_ref = mutation.addedNodes) != null ? _ref[0] : void 0).nodeName !== 'DIV') {
- return;
- }
- Main.findNodes([node]);
- }
- });
- config = {
- attributes: true,
- childList: true,
- characterData: false
- };
- return observer.observe(Main.thread, config);
- }
- };
- (wait = function() {
- /*
- Why does @run-at exist? No one knows.
- */
- if (d != null ? d.body : void 0) {
- return Main.init();
- } else {
- return setTimeout(wait, 30);
- }
- })();
- }).call(this);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement