Skip to content

Instantly share code, notes, and snippets.

@vitouXY
Last active May 1, 2023 01:05
Show Gist options
  • Save vitouXY/92f8f40011933457e668ffcaed4ed0d3 to your computer and use it in GitHub Desktop.
Save vitouXY/92f8f40011933457e668ffcaed4ed0d3 to your computer and use it in GitHub Desktop.
API - Bolsa de Santiago de Chile - (Chrome Extension - Custom JavaScript for Websites 2 - Run custom JavaScript on any website.)
/*
var script = document.createElement('script');
script.setAttribute('src', 'https://example.com/bcs_code03.js');
script.setAttribute('type', 'text/javascript');
document.getElementsByTagName('head')[0].appendChild(script);
*/
const NemoTecnico = prompt('NemoTecnico:','CFIETFGE');
alert(`get_${NemoTecnico}.json`);
(async function() {
let allData = '';
let jsonData;
let jsonFmt;
jsonData = await new Promise(resolve => {
angular.element(document.body).injector().get('RV_Instrumentos')['getResumenInstrumento']({
nemo: NemoTecnico,
}, data => resolve(data));
});
jsonFmt = JSON.stringify(jsonData).replace('listaResult','getResumenInstrumento');
allData += `${jsonFmt},\n`;
jsonData = await new Promise(resolve => {
angular.element(document.body).injector().get('RV_Instrumentos')['getResumenPrecios']({
nemo: NemoTecnico,
}, data => resolve(data));
});
jsonFmt = JSON.stringify(jsonData).replace('listaResult','getResumenPrecios');
allData += `${jsonFmt},\n`;
jsonData = await new Promise(resolve => {
angular.element(document.body).injector().get('RV_Instrumentos')['getUltimasTransacciones']({
nemo: NemoTecnico,
}, data => resolve(data));
});
jsonFmt = JSON.stringify(jsonData).replace('listaResult','getUltimasTransacciones');
allData += `${jsonFmt},\n`;
jsonData = await new Promise(resolve => {
angular.element(document.body).injector().get('RV_Instrumentos')['getUltimasVariacionesCapital']({
nemo: NemoTecnico,
tamanopag: 0,
pagina: 0,
}, data => resolve(data));
});
jsonFmt = JSON.stringify(jsonData).replace('listaResult','getUltimasVariacionesCapital');
allData += `${jsonFmt},\n`;
jsonData = await new Promise(resolve => {
angular.element(document.body).injector().get('RV_ResumenMercado')['getDividendos']({
nemo: NemoTecnico,
fec_pagoini: `2023-01-01`,
fec_pagofin: `2023-12-31`,
}, data => resolve(data));
});
jsonFmt = JSON.stringify(jsonData).replace('listaResult','getDividendos');
allData += `${jsonFmt},\n`;
jsonData = await new Promise(resolve => {
angular.element(document.body).injector().get('RV_Instrumentos')['getPuntasCompraVenta']({
nemo: NemoTecnico,
}, data => resolve(data));
});
jsonFmt = JSON.stringify(jsonData).replace('listaResult','getPuntasCompraVenta');
allData += `${jsonFmt},\n`;
jsonData = await new Promise(resolve => {
angular.element(document.body).injector().get('RV_Instrumentos')['getRentabilidad']({
nemo: NemoTecnico,
idioma: 'es',
}, data => resolve(data));
});
jsonFmt = JSON.stringify(jsonData).replace('listaResult','getRentabilidad');
allData += `${jsonFmt},\n`;
jsonData = await new Promise(resolve => {
angular.element(document.body).injector().get('RV_Instrumentos')['getMetaIntraday']({
symbol: NemoTecnico,
time: '',
}, data => resolve(data));
});
jsonFmt = JSON.stringify(jsonData).replace('listaResult','getMetaIntraday');
allData += `${jsonFmt},\n`;
jsonData = await new Promise(resolve => {
angular.element(document.body).injector().get('RV_Instrumentos')['getOtraInformacion']({
nemo: NemoTecnico,
tipo_informacion: 'Reseña Compañía',
}, data => resolve(data));
});
jsonFmt = JSON.stringify(jsonData).replace('listaResult','getOtraInformacion');
allData += `${jsonFmt},\n`;
jsonData = await new Promise(resolve => {
angular.element(document.body).injector().get('RV_ResumenMercado')['getETFs']({
Etf: NemoTecnico,
Idioma: 'Español',
}, data => resolve(data));
});
jsonFmt = JSON.stringify(jsonData).replace('listaResult','getETFs');
allData += `${jsonFmt},\n`;
jsonData = await new Promise(resolve => {
angular.element(document.body).injector().get('RV_ResumenMercado')['getETFCreacionDetalle']({
vetf: NemoTecnico,
}, data => resolve(data));
});
jsonFmt = JSON.stringify(jsonData).replace('listaResult','getETFCreacionDetalle');
allData += `${jsonFmt},\n`;
jsonData = await new Promise(resolve => {
angular.element(document.body).injector().get('RV_ResumenMercado')['getETFCreacionTotales']({
vetf: NemoTecnico,
}, data => resolve(data));
});
jsonFmt = JSON.stringify(jsonData).replace('listaResult','getETFCreacionTotales');
allData += `${jsonFmt},\n`;
jsonData = await new Promise(resolve => {
angular.element(document.body).injector().get('RV_Indices')['getIndiceIntraday']({
symbol: NemoTecnico,
condividendo: 'S',
}, data => resolve(data));
});
jsonFmt = JSON.stringify(jsonData).replace('listaResult','getIndiceIntraday');
allData += `${jsonFmt},\n`;
jsonData = await new Promise(resolve => {
angular.element(document.body).injector().get('RV_Indices')['getEmpresasIndice']({
indice: NemoTecnico,
dividendo: 'S',
}, data => resolve(data));
});
jsonFmt = JSON.stringify(jsonData).replace('listaResult','getEmpresasIndice');
allData += `${jsonFmt},\n`;
jsonData = await new Promise(resolve => {
angular.element(document.body).injector().get('RV_Indices')['getIndice']({
indice: NemoTecnico,
dividendo: 'S',
}, data => resolve(data));
});
jsonFmt = JSON.stringify(jsonData).replace('listaResult','getIndice');
allData += `${jsonFmt},\n`;
jsonData = await new Promise(resolve => {
angular.element(document.body).injector().get('RV_Indices')['getDescIndices']({
Indice: NemoTecnico,
}, data => resolve(data));
});
jsonFmt = JSON.stringify(jsonData).replace('listaResult','getDescIndices');
allData += `${jsonFmt},\n`;
jsonData = await new Promise(resolve => {
angular.element(document.body).injector().get('RV_Indices')['getMetodCalculoIndice']({
indice: NemoTecnico,
}, data => resolve(data));
});
jsonFmt = JSON.stringify(jsonData).replace('listaResult','getMetodCalculoIndice');
allData += `${jsonFmt},\n`;
let allJData = `{"${NemoTecnico}":[${allData}]}\n`;
const element = document.createElement('a');
element.setAttribute('href', `data:text/json;charset=utf-8,${encodeURIComponent(allJData)}`);
element.setAttribute('download', `get_${NemoTecnico}.json`);
element.style.display = 'none';
document.body.appendChild(element);
element.click();
document.body.removeChild(element);
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment