Skip to content

Instantly share code, notes, and snippets.

@fredgido
Last active February 6, 2020 04:51
Show Gist options
  • Save fredgido/abb10784e70de97da2d5201b53d0e66e to your computer and use it in GitHub Desktop.
Save fredgido/abb10784e70de97da2d5201b53d0e66e to your computer and use it in GitHub Desktop.
// ==UserScript==
// @name Seiga-rusher-boy
// @match https://www.nicovideo.jp/my/top/all*
// @description made by fredgy-kun
// @grant GM_notification
// @grant window.focus
// @grant window.focus
// ==/UserScript==
var nd = {
text: "Seiga-rusher-boy",
title: "running" ,
timeout: 15000,
image: 'https://lohas.nicoseiga.jp/thumb/10087499z', //url_w
onclick: function() { window.focus(); },
};
//console.log(nd);
GM_notification(nd);
console.log('starid: '+localStorage.getItem('apple'));
//localStorage.setItem('apple',localStorage.getItem('apple')- 1);
var warnaudio = new Audio('https://files.catbox.moe/jrb0wc.mp3');
warnaudio.addEventListener('ended', () => {location.reload();});
//warnaudio.play();
var getJSON = function(url, callback) {
var xhr = new XMLHttpRequest();
xhr.open('GET', url, true);
xhr.responseType = 'json';
xhr.onload = function() {
var status = xhr.status;
if (status === 200) {
callback(null, xhr.response);
} else {
callback(status, xhr.response);
}
};
xhr.send();
return xhr.response;
}
function getlatestis(file) {
var largest = 0;
file.data.forEach(function(elem){
if(elem.topic == "nicoseiga.user.illust.upload" && elem.illustImage.id > largest){
largest = elem.illustImage.id;}
});
return largest;
}
function getauthor(file,id) {
var largest ;
file.data.forEach(function(elem){
if(elem.topic == "nicoseiga.user.illust.upload" && elem.illustImage.id == id){
console.log("user id "+elem.senderNiconicoUser.id );
largest = elem.senderNiconicoUser.id;
}});
return largest;
}
function title(file,id) {
var largest ;
file.data.forEach(function(elem){
if(elem.topic == "nicoseiga.user.illust.upload" && elem.illustImage.id == id){
console.log("title "+elem.illustImage.title );
largest = elem.illustImage.title}
});
return largest;
}
function myFn() {
getJSON('https://www.nicovideo.jp/api/nicorepo/timeline/my/followingUser?client_app=pc_myrepo', function(err, data) {
if (err !== null) {
console.log('Something went wrong: ' + err);
}
else {
console.log('Hello I wan ');
console.log('Checkout the latest id ',getlatestis(data));
var last = getlatestis(data);
if(localStorage.getItem('apple') < last){
console.log('IT IS NEW');
var idtoget = getauthor(data,last);
console.log("autor id "+idtoget);
var titletxt = title(data,last);
console.log("autor text "+idtoget);
var danname = new XMLHttpRequest();
danname.open('GET', "https://danbooru.donmai.us/artists.json?search[url_matches]=http://seiga.nicovideo.jp/user/illust/"+idtoget+"&search[is_active]=true&only=id,name,is_banned,other_names,urls", false); // `false` makes the request synchronous
danname.send(null);
console.log("dan" +danname.status);
if (danname.status === 200) {
console.log(danname.responseText);
}
var notificationDetails = {
text: titletxt,
title: JSON.parse(danname.responseText)[0].name ,
timeout: 15000,
image: "https://lohas.nicoseiga.jp/thumb/"+last+"z", //url_w
onclick: function() { window.focus(); },
};
console.log(notificationDetails);
GM_notification(notificationDetails);
localStorage.setItem('apple', last);
warnaudio.play(); // maybe it works now
}
}
}
);
}
setInterval(myFn, 5000)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment