Skip to content

Instantly share code, notes, and snippets.

@and-rom
Last active May 21, 2020 12:28
Show Gist options
  • Select an option

  • Save and-rom/1f4e89c326437c3289ce079f831e936d to your computer and use it in GitHub Desktop.

Select an option

Save and-rom/1f4e89c326437c3289ce079f831e936d to your computer and use it in GitHub Desktop.
Beeline Services
// ==UserScript==
// @name Beeline Services
// @namespace https://gist.github.com/and-rom/1f4e89c326437c3289ce079f831e936d
// @version 0.5
// @author and-rom
// @description List all enabled services.
// @homepage https://gist.github.com/and-rom/1f4e89c326437c3289ce079f831e936d
// @icon https://my.beeline.ru/resources/icon/favicon.ico
// @icon64 https://static.beeline.ru/upload/images/b2c/bee-logo/single.png
// @updateURL https://gist.github.com/and-rom/1f4e89c326437c3289ce079f831e936d/raw/beeline-services.meta.js
// @downloadURL https://gist.github.com/and-rom/1f4e89c326437c3289ce079f831e936d/raw/beeline-services.user.js
// @match https://my.beeline.ru/*
// @grant none
// ==/UserScript==
// ==UserScript==
// @name Beeline Services
// @namespace https://gist.github.com/and-rom/1f4e89c326437c3289ce079f831e936d
// @version 0.5
// @author and-rom
// @description List all enabled services.
// @homepage https://gist.github.com/and-rom/1f4e89c326437c3289ce079f831e936d
// @icon https://my.beeline.ru/resources/icon/favicon.ico
// @icon64 https://static.beeline.ru/upload/images/b2c/bee-logo/single.png
// @updateURL https://gist.github.com/and-rom/1f4e89c326437c3289ce079f831e936d/raw/beeline-services.meta.js
// @downloadURL https://gist.github.com/and-rom/1f4e89c326437c3289ce079f831e936d/raw/beeline-services.user.js
// @match https://my.beeline.ru/*
// @grant none
// ==/UserScript==
(function() {
'use strict';
$(`
<style type='text/css'>
#ex-menu,#ex-container {
display: none;
}
#ex-menu ~ label:before {
display: inline;
content: "показать";
}
#ex-menu:checked ~ label:before {
content: "скрыть";
}
#ex-menu:checked ~ #ex-container {
display:block;
}
#ex-container {
width: 100%;
text-align: center;
position: fixed;
top: 10px;
left: 0;
z-index: 1000;
background-color: #fff;
height: calc(100% - 10px);
}
#ex-accounts {
width: 50%;
height: 100px;
}
#ex-result{
overflow-y: scroll;
height: calc(100% - 150px);
position: relative;
text-align: initial;
padding: 0 20px;
font-size: 16px;
}
</style>
`).appendTo("head");
$('body').prepend(`
<input type="checkbox" id="ex-menu"><label for="ex-menu"></label>
<div id="ex-container">
<textarea id="ex-accounts">9012345678,XXXXXX
9012345678,XXXXXX
</textarea>
<br>
<button id="ex-submit">get</button>
<div id="ex-result"></div>
</div>
`);
$('#ex-submit').click(function() {
let accounts = [];
var lines = $('#ex-accounts').val().split('\n');
for(var i = 0;i < lines.length;i++){
let line=lines[i].split(",");
let account = new Object();
account.login = line[0];
account.passw = line[1];;
accounts.push(account);
}
console.log(accounts);
accounts.forEach(function(account){
$.ajax({
url: "https://my.beeline.ru/api/1.0/auth",
type: "GET",
data: {
login: account.login,
password: account.passw
},
complete: function(jqXHR, textStatus) {
switch (jqXHR.status) {
case 200:
$.ajax({
url: "https://my.beeline.ru/api/1.0/info/serviceList",
type: "GET",
data: {
ctn: account.login,
token: jqXHR.responseJSON.token
},
complete: function(jqXHR, textStatus) {
switch (jqXHR.status) {
case 200:
console.log(jqXHR.responseJSON.services);
$('#ex-result').append('<h3>' + account.login + '</h3>');
$('#ex-result').append('<table>');
jqXHR.responseJSON.services.forEach(function(services){
$.each( services, function( key, value ) {
$('#ex-result').append('<tr><td>' + key + '</td><td>' + (key == 'baseFeatures' ? JSON.stringify(value) : value) + '</td>');
});
$('#ex-result').append('<tr><td>&nbsp;</td><td>&nbsp;</td>');
});
$('#ex-result').append('</table>');
break;
default:
console.log('Какая-то ошибка!');
}
}
});
break;
default:
console.log('Какая-то ошибка!');
}
}
});
});
});
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment