Skip to content

Instantly share code, notes, and snippets.

@fredgido
Last active June 10, 2023 16:18
Show Gist options
  • Save fredgido/616719015ac7da4ce0ffeaaa7e456e3a to your computer and use it in GitHub Desktop.
Save fredgido/616719015ac7da4ce0ffeaaa7e456e3a to your computer and use it in GitHub Desktop.
// ==UserScript==
// @name Pixiv-rusher-boy
// @namespace PRB
// @version 0.0000000001
// @match https://www.pixiv.net/bookmark_new_illust.php
// @description made by fredgy-kun
// @grant GM_notification
// @grant window.focus
// @grant window.focus
// ==/UserScript==
console.log('starid: '+localStorage.getItem('banana'));
//localStorage.setItem('banana',localStorage.getItem('banana')- 1);
var warnaudio = new Audio('https://files.catbox.moe/amlyta.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 myFn() {
getJSON('https://www.pixiv.net/touch/ajax/follow/latest?type=illusts&p=1&include_meta=1', function(err, data) {
if (err !== null) {
console.log('Something went wrong: ' + err);
}
else {
console.log('Hello I wan ');
console.log('Checkout the latest id ', data.body["illusts"][0]["id"]);
if(localStorage.getItem('banana') < data.body["illusts"][0]["id"]){
console.log('IT IS NEW');
var idtoget = data.body["illusts"][0]["author_details"]["user_id"];
console.log(idtoget);
var danname = new XMLHttpRequest();
danname.open('GET', "https://danbooru.donmai.us/artists.json?search[url_matches]=https://www.pixiv.net/member.php?id="+idtoget+"&search[is_active]=true&only=id,name,is_banned,other_names,urls", false); // `false` makes the request synchronous
danname.send(null);
if (danname.status === 200) {
console.log(danname.responseText);
}
var notificationDetails = {
text: data.body["illusts"][0]["author_details"]["user_account"]+" - "+data.body["illusts"][0]["author_details"]["user_name"]+" - "+data.body["illusts"][0]["title"],
title: JSON.parse(danname.responseText)[0]?.name ,
timeout: 30000,
image: data.body["illusts"][0]["url_s"].replace("pximg.net","pixiv.cat"),
onclick: function() { window.focus(); },
};
console.log(notificationDetails);
//GM.notification( text, title, image, onclick )
GM_notification(notificationDetails);
localStorage.setItem('banana', data.body["illusts"][0]["id"]);
warnaudio.play(); // maybe it works now
}
}
}
);
}
setInterval(myFn, 30000)
@NamelessContributor
Copy link

Danbooru's image proxy was removed. Because of this, notifications don't display at all on Tampermonkey (and possibly others).
To fix this, replace line 62:

image: data.body["illusts"][0]["url_s"].replace('pximg.net', 'pixiv.cat'), // image_proxy is dead

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment