Skip to content

Instantly share code, notes, and snippets.

@NaokiStark
Created January 5, 2018 13:10
Show Gist options
  • Save NaokiStark/e14ebec107805fc1440b4128f9a046b1 to your computer and use it in GitHub Desktop.
Save NaokiStark/e14ebec107805fc1440b4128f9a046b1 to your computer and use it in GitHub Desktop.
// ==UserScript==
// @name Taringa! Switcher
// @namespace http://www.taringa.ml/
// @version 0.1
// @description Switch between different user accounts in Taringa!
// @author anpep
// @match *://*.taringa.net/*
// @grant none
// ==/UserScript==
var accounts = [
{
id: 1,
nick: 'puto',
avatar: 'bija.jpg',
pass: 'puto'
},
/* pega desde { hasta el } aquí para añadir más usuarios */
];
$('body').prepend([
'<style type="text/css">',
'#tool-switcher {',
' left: -136px;',
'}',
'#tool-switcher .unread {',
' border: none;',
' font-weight: bold;',
' background: #f2fbff url(bullet.png) no-repeat!important;',
'}',
'.v6 .header .login .user-actions .user-action .ico-usuario:before {',
' font-family: "icomoon";',
' content: "\\e971";',
' color: inherit;',
' font-size: 1em;',
' line-height: 1em;',
' font-weight: normal;',
' font-style: normal;',
' text-decoration: inherit;',
' text-transform: none;',
' -webkit-font-smoothing: antialiased;',
' -moz-osx-font-smoothing: grayscale;',
' padding: 0 0 0 7px!important;',
'}',
'</style>'
].join(''));
$('.user-actions').prepend([
'<div class="user-action">',
' <a href="#" class="ico-usuario tool-switcher"></a>',
' <div id="tool-switcher" class="tools hide">',
' <h4>Cuentas de usuario</h4>',
' <ul></ul>',
' </div>',
'</div>'
].join(''));
$('.tool-switcher').click(function(event) {
event.stopPropagation();
event.preventDefault();
var switcher = $('#tool-switcher');
switcher.toggle();
if(!$('.tools').hasClass('hide'))
$('.tools').addClass('hide');
if (switcher.is(':visible') && switcher.find('ul li').length === 0) {
var list = switcher.find('ul');
accounts.forEach(function(data, index) {
list.append([
'<li' + (global_data.user == data.id ? ' class="unread"' : '') + '>',
'<a href="#" class="switch-account" data-index="' + index + '">',
'<img src="' + data.avatar + '" href="/' + data.nick + '">',
'<h5>' + data.nick + '</h5>',
'<p>#' + data.id + '</p>',
'</a>',
'</li>'
].join(''));
});
}
});
$('.user-action > a:not(.tool-switcher)').bind('click', function() {
$('#tool-switcher').addClass('hide');
});
$('body').on('click', '.switch-account', function(e) {
e.preventDefault();
e.stopPropagation();
var account = accounts[+$(this).attr('data-index')];
$.post('/ajax/user/logout').always(function() {
$.ajax({
url: '/registro/login-submit.php',
type: 'post',
dataType: 'json',
beforeSend: function() {},
data: {
key: undefined,
nick: account.nick,
pass: account.pass,
connect: '',
redirect: '/' + window.location.pathName
},
success: function(data) {
document.location.reload();
}
});
});
});
//function = get.TodosLosDatosDeAnpepe
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment