Last active
November 10, 2019 05:31
-
-
Save BubuInc/3b171ebfcd85190e3b62 to your computer and use it in GitHub Desktop.
Taringa! Hide Photos in comments
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name Oculta Fotos en comentarios | |
// @namespace mangareader | |
// @description Oculta fotos en los comentarios | |
// @include http://www.taringa.net/posts/* | |
// @include http://www.taringa.net/post/* | |
// @exclude http://www.taringa.net/posts/editar/* | |
// @version 1 | |
// @grant none | |
// ==/UserScript== | |
window.initOculta = function (event) { | |
event.preventDefault(); | |
var url = prompt('Ingresa la url de la imagen'); | |
if(url){ | |
var imgEl = new Image(); | |
imgEl.onerror = function() {alert('La imagen no se pudo cargar'); this.parentNode.removeChild(this); }; | |
imgEl.onload = function () { | |
if (imgEl.naturalHeight>1000 || imgEl.naturalWidth>1000) { | |
alert('La imagen es demasiado grande'); | |
}else{ | |
var r = confirm('¿Es esta la imagen que quieres ocultar?'); | |
this.parentNode.removeChild(this); | |
if (r) {modGif(url); } | |
} | |
}; | |
imgEl.setAttribute('style','position:fixed;top:0;right:0;bottom:0;left:0;margin:auto;border:30px solid #888;max-width:80%;max-height:80%;z-index:10000;border-style:double;' ); | |
document.body.appendChild(imgEl); | |
imgEl.src = url; | |
}else{alert('url no valida');} | |
window. modGif = function (url) { // Formato de gif: http://www.matthewflickinger.com/lab/whatsinagif/bits_and_bytes.asp | |
var gifBytes = [71,73,70,56,57,97,29,0,25,0,162,7,0,69,69,69,255,234,0,255,180,0,255,204,0,255,255,179,255,253,17,254,157,0,255,255,255,33,255,11,78,69,84,83,67,65,80,69,50,46,48,3,1,0,0,0,33,249,4,9,6,0,7,0,44,0,0,0,0,29,0,25,0,0,3,131,120,186,220,11,46,74,7,4,100,224,78,89,245,233,219,4,42,99,200,89,153,101,114,157,165,174,148,32,183,30,252,84,242,108,159,122,152,253,145,78,141,2,32,24,9,131,12,230,181,41,18,10,133,128,116,96,184,148,68,198,168,116,75,77,13,131,132,204,246,23,72,50,155,207,241,118,90,133,21,163,98,169,120,112,70,203,1,99,60,253,27,212,174,215,123,110,3,127,127,93,54,0,131,119,115,73,59,136,131,120,99,134,141,3,148,149,148,109,59,36,56,50,85,124,110,63,158,153,162,11,9,0,33,249,4,9,6,0,7,0,44,0,0,0,0,29,0,25,0,0,3,131,120,186,220,11,46,74,7,4,100,224,78,89,245,233,219,4,42,99,200,89,153,101,114,157,165,174,148,32,183,30,252,84,242,108,159,122,152,253,145,78,141,2,32,24,9,131,12,230,181,41,18,10,133,128,116,96,184,148,68,198,168,116,75,77,13,131,79,237,118,122,197,70,51,219,95,23,86,20,7,0,227,1,211,71,72,195,165,25,249,55,40,70,227,1,122,108,3,99,132,1,107,130,133,83,73,59,128,131,127,121,85,59,31,3,148,141,148,145,146,31,56,50,85,123,108,63,158,153,162,7,9,0,33,249,4,9,6,0,7,0,44,0,0,0,0,29,0,25,0,0,3,127,120,186,220,11,46,74,7,4,100,224,78,89,245,233,219,4,42,99,200,89,153,101,114,157,165,174,148,32,183,30,252,84,242,108,159,250,30,117,53,81,38,211,40,133,50,132,36,97,64,252,188,76,128,100,161,16,168,14,12,169,32,71,90,237,6,174,205,85,148,234,237,50,109,227,178,23,12,75,103,186,195,193,243,72,40,3,214,243,13,128,28,120,87,51,114,90,63,3,106,107,88,104,132,133,3,103,136,137,107,108,59,0,139,139,67,0,135,62,31,45,2,88,130,109,149,62,9,0]; //menos el ultimo(59) | |
var url = 'img='+url; | |
url = btoa(url); //Codificar en base 64 | |
var Str = url.match(/.{1,255}/g); // Dividir en strings de 255 caracteres | |
gifBytes.push(0x21); gifBytes.push(0xFE); // cabecera de bloque de comentario | |
for (var i = 0; i < Str.length; i++) { // Por cada substring crear el sub-bloque de comentario | |
gifBytes.push(Str[i].length); // cabecera de sub-bloque de comentario (longitud del sub-bloque) | |
for (var j = 0; j < Str[i].length; j++) { gifBytes.push(Str[i].charCodeAt(j));}//Bytes del sub-bloque | |
} | |
gifBytes.push(0x00,0x3B); // Cierra el bloque con un byte 00 y el gif con un byte 3B | |
var byteAr = new Uint8Array(gifBytes); | |
var blob = new Blob([byteAr.buffer],{type : 'application/octet-stream'}); | |
//Upload | |
var fileName = ('0000'+Math.random().toString(36).replace('.', '')).substr(-6)+'.gif'; | |
var fd = new FormData(); | |
fd.append('Filename', fileName); | |
fd.append('fileext', '*.gif;*.jpeg;*.jpg;*.png'); | |
fd.append('folder', window.location.pathname.match(/.*\//)); | |
fd.append('file', blob, fileName); | |
fd.append('Upload', 'Submit Query'); | |
if (kn3UploadUrl) { | |
var ajax = new XMLHttpRequest(); | |
ajax.open('POST', decodeURIComponent(kn3UploadUrl)); | |
ajax.onload = function () { | |
var url = JSON.parse(ajax.response).error; | |
if (!url.match(/^http/)) { | |
alert('Error al subir y procesar el emoticon\nKn3.net dice:\n'+url+'\n\nTrata otra vez'); | |
}else { | |
var bb = '[img='+url+']'; | |
var textArea = document.querySelector('#cont_comm textarea'); | |
var start = textArea.selectionStart, end = textArea.selectionEnd; | |
textArea.value = textArea.value.substring(0,start) + bb + textArea.value.substring(end,tALen); | |
} | |
}; | |
ajax.onerror = function () {alert('No se pudo conectar con el servidor de imagenes kn3.net');}; | |
ajax.send(fd); | |
}else{alert('No se pudo encontrar la url para subir el emoticon')} | |
} | |
// Agregar boton | |
var li = document.createElement('li'); | |
li.classList.add('markItUpButton'); | |
li.setAttribute('style','background-color:black!important;height:30px;width:20px'); | |
var a = document.createElement('a'); | |
a.title = "Insertar foto oculta"; | |
a.href = ""; | |
a.setAttribute('onclick','initOculta(event)'); | |
li.appendChild(a); | |
document.querySelector('.markItUpHeader ul').appendChild(li); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment