/)[2];
return "[" + (link.length > 200 ? link.slice(0,200) + "…" : link) + "]";
})
text.innerHTML = DOMPurify.sanitize(imgText)//reason for inner HTML: preparsed sanitized HTML from the Anilist API
}
else{
text.innerHTML = DOMPurify.sanitize(reply.text)//reason for inner HTML: preparsed sanitized HTML from the Anilist API
}
Array.from(text.querySelectorAll(".youtube")).forEach(ytLink => {
create("a",["link","newTab"],"Youtube " + ytLink.id,ytLink)
.href = "https://www.youtube.com/watch?v=" + ytLink.id;
});
let actions = create("div","actions",false,rep,"position:absolute;text-align:right;right:4px;bottom:0px;");
let likeWrap = create("span",["action","hohLikes"],false,actions,"display:inline-block;min-width:35px;margin-left:2px");
likeWrap.title = reply.likes.map(a => a.name).join("\n");
let likeCount = create("span","count",(reply.likes.length ? reply.likes.length : " "),likeWrap);
let heart = create("span",false,"♥",likeWrap,"position:relative;");
let likeQuickView = create("div","hohLikeQuickView",false,heart,"position:absolute;bottom:0px;left:30px;font-size:70%;white-space:nowrap;");
likeWrap.style.cursor = "pointer";
if(reply.likes.some(like => like.name === whoAmI)){
likeWrap.classList.add("hohILikeThis");
};
likeify(reply.likes,likeQuickView);
likeWrap.onclick = function(){
authAPIcall(
"mutation($id:Int){ToggleLike(id:$id,type:ACTIVITY_REPLY){id}}",
{id: reply.id},
data => {}
);
if(likeWrap.classList.contains("hohILikeThis")){
reply.likes.splice(reply.likes.findIndex(user => user.name === whoAmI),1);
if(reply.likes.length === 0){
likeCount.innerText = " ";
}
else{
likeCount.innerText = reply.likes.length;
};
}
else{
reply.likes.push({name: whoAmI});
likeCount.innerText = reply.likes.length;
};
likeWrap.classList.toggle("hohILikeThis");
likeWrap.title = reply.likes.map(a => a.name).join("\n");
likeify(reply.likes,likeQuickView);
};
});
let statusInput = create("div",false,false,replies);
let inputArea = create("textarea",false,false,statusInput,"width: 99%;border-width: 1px;padding: 4px;border-radius: 2px;color: rgb(159, 173, 189);resize: vertical;");
let cancelButton = create("button",["hohButton","button"],"Cancel",statusInput,"background:rgb(31,35,45);display:none;color: rgb(159, 173, 189);");
let publishButton = create("button",["hohButton","button"],"Publish",statusInput,"display:none;");
inputArea.placeholder = "Write a reply...";
inputArea.onfocus = function(){
cancelButton.style.display = "inline";
publishButton.style.display = "inline";
};
cancelButton.onclick = function(){
inputArea.value = "";
cancelButton.style.display = "none";
publishButton.style.display = "none";
document.activeElement.blur();
};
publishButton.onclick = function(){
loading.innerText = "Publishing reply...";
authAPIcall(
`mutation($text: String,$activityId: Int){
SaveActivityReply(text: $text,activityId: $activityId){
id
user{name}
likes{name}
text(asHtml: true)
createdAt
}
}`,
{text: emojiSanitize(inputArea.value),activityId: activity.id},
data => {
loading.innerText = "";
if(data){
activity.replies.push(data.data.SaveActivityReply);
replyCount.innerText = activity.replies.length;
act.lastChild.remove();
createReplies()
}
}
);
inputArea.value = "";
cancelButton.style.display = "none";
publishButton.style.display = "none";
document.activeElement.blur();
};
};createReplies();
};
};
let status;
if(activity.type === "TEXT" || activity.type === "MESSAGE"){
status = create("div",false,false,content,"padding-bottom:10px;width:95%;overflow-wrap:anywhere;");
activity.text = "" + activity.text.replace(/\n\n/g,"
") + "
";//workaround for API bug
if(useScripts.termsFeedNoImages){
let imgText = activity.text.replace(//g,img => {
let link = img.match(//)[2];
return "[" + (link.length > 200 ? link.slice(0,200) + "…" : link) + "]";
}).replace(//g,video => {
let link = video.match(/src=("|')(.*?)("|')/)[2];
return "[" + (link.length > 200 ? link.slice(0,200) + "…" : link) + "]";
})
status.innerHTML = DOMPurify.sanitize(imgText);//reason for inner HTML: preparsed sanitized HTML from the Anilist API
if(imgText !== activity.text){
let render = create("a",false,"IMG",act,"position:absolute;top:2px;right:50px;width:10px;cursor:pointer;");
render.title = "load images";
render.onclick = () => {
activity.renderingPermission = true;
status.innerHTML = DOMPurify.sanitize(activity.text);//reason for inner HTML: preparsed sanitized HTML from the Anilist API
render.style.display = "none";
}
}
}
else{
status.innerHTML = DOMPurify.sanitize(activity.text);//reason for inner HTML: preparsed sanitized HTML from the Anilist API
}
Array.from(status.querySelectorAll(".youtube")).forEach(ytLink => {
create("a",["link","newTab"],ytLink.id,ytLink)
.href = ytLink.id
});
if(activity.user.name === whoAmI && activity.type === "TEXT" && type !== "thread"){
let edit = create("a",false,"Edit",act,"position:absolute;top:2px;right:40px;width:10px;cursor:pointer;font-size:small;color:inherit;");
if(useScripts.termsFeedNoImages){
edit.style.right = "80px"
}
edit.onclick = function(){
loading.innerText = "Loading activity " + activity.id + "...";
if(terms.scrollIntoView){
terms.scrollIntoView({"behavior": "smooth","block": "start"})
}
else{
document.body.scrollTop = document.documentElement.scrollTop = 0
};
authAPIcall(
`query($id: Int){
Activity(id: $id){
... on TextActivity{
text(asHtml: false)
}
}
}`,
{id: activity.id},
data => {
if(!data){
onlySpecificActivity = false;
loading.innerText = "Failed to load activity";
}
inputArea.focus();
onlySpecificActivity = activity.id;
loading.innerText = "Editing activity " + activity.id;
inputArea.value = data.data.Activity.text;
}
)
}
}
act.classList.add("text");
actions.style.right = "21px";
actions.style.bottom = "4px";
}
else{
status = create("span",false," " + activity.status,content);
if(activity.progress){
create("span",false," " + activity.progress + " of",content);
};
let title = activity.media.title.romaji;
if(useScripts.titleLanguage === "NATIVE" && activity.media.title.native){
title = activity.media.title.native;
}
else if(useScripts.titleLanguage === "ENGLISH" && activity.media.title.english){
title = activity.media.title.english;
};
dataMedia.add(title);
title = titlePicker(activity.media);
let media = create("a",["link","newTab"]," " + title,content);
media.href = "/" + activity.media.type.toLowerCase() + "/" + activity.media.id + "/" + safeURL(title) + "/";
if(activity.media.type === "MANGA" && useScripts.CSSgreenManga){
media.style.color = "rgb(var(--color-green))";
};
act.classList.add("list");
actions.style.right = "21px";
actions.style.top = "2px";
if(useScripts.statusBorder){
let blockerMap = {
"plans": "PLANNING",
"watched": "CURRENT",
"read": "CURRENT",
"completed": "COMPLETED",
"paused": "PAUSED",
"dropped": "DROPPED",
"rewatched": "REPEATING",
"reread": "REPEATING"
};
let status = blockerMap[
Object.keys(blockerMap).find(
key => activity.status.includes(key)
)
]
if(status === "CURRENT"){
//nothing
}
else if(status === "COMPLETED"){
act.style.borderLeftWidth = "3px";
act.style.marginLeft = "-2px";
if(useScripts.CSSgreenManga && activity.media.type === "ANIME"){
act.style.borderLeftColor = "rgb(var(--color-blue))";
}
else{
act.style.borderLeftColor = "rgb(var(--color-green))";
}
}
else{
act.style.borderLeftWidth = "3px";
act.style.marginLeft = "-2px";
act.style.borderLeftColor = distributionColours[status];
}
}
};
let link = create("a",["link","newTab"],false,act,"position:absolute;top:2px;right:4px;width:10px;");
link.appendChild(svgAssets2.link.cloneNode(true));
if(type === "thread"){
link.href = "https://anilist.co/forum/thread/" + activity.id + "/"
}
else{
link.href = "https://anilist.co/" + type + "/" + activity.id + "/"
}
if(activity.user.name === whoAmI){
let deleteActivity = create("span","hohDeleteActivity",svgAssets.cross,act);
deleteActivity.title = "Delete";
deleteActivity.onclick = function(){
authAPIcall(
"mutation($id: Int){Delete" + capitalize(type) + "(id: $id){deleted}}",
{id: activity.id},
function(data){
if(data.data.DeleteActivity.deleted){
act.style.display = "none"
}
}
)
}
}
dataUsers.add(activity.user.name);
activity.replies.forEach(reply => {
dataUsers.add(reply.user.name);
(reply.text.match(/@(.*?) {
dataUsers.add(user.slice(1,user.length-1))
})
})
});
if(terms.scrollIntoView){
terms.scrollIntoView({"behavior": "smooth","block": "start"})
}
else{
document.body.scrollTop = document.documentElement.scrollTop = 0
};
removeChildren(dataUsersList)
dataUsers.forEach(user => {
create("option",false,false,dataUsersList)
.value = user;
});
removeChildren(dataMediaList)
dataMedia.forEach(media => {
create("option",false,false,dataMediaList)
.value = media;
});
};
let requestPage = function(npage,userID){
page = npage;
changeURL();
let types = [];
if(!onlyUser.checked || date){
types.push("MESSAGE")
}
if(onlyStatus.checked){
types.push("ANIME_LIST","MANGA_LIST")
};
let specificUser = onlyUserInput.value || whoAmI;
if(onlyUser.checked && !userID){
generalAPIcall("query($name:String){User(name:$name){id}}",{name: specificUser},function(data){
if(data){
requestPage(npage,data.data.User.id)
}
else{
loading.innerText = "Not Found"
}
},"hohIDlookup" + specificUser.toLowerCase());
return;
};
let requestTime = NOW();
if(onlyForum.checked){
authAPIcall(
`
query($page: Int){
Page(page: $page){
threads(sort:REPLIED_AT_DESC${(onlyUser.checked ? ",userId: " + userID : "")}${onlyMedia.checked && onlyMediaResult.id ? ",mediaCategoryId: " + onlyMediaResult.id : ""}){
id
createdAt
user{name}
text:body(asHtml: true)
likes{name}
title
replyCount
}
}
Viewer{unreadNotificationCount}
}`,
{page: npage},
function(data){
buildPage(data.data.Page.threads.map(thread => {
thread.type = "TEXT";
thread.replies = [];
thread.text = "" + thread.title + "
" + thread.text;
return thread
}).filter(thread => thread.replyCount || !onlyReplies.checked),"thread",requestTime);
handleNotifications(data);
}
);
}
else if(onlyReviews.checked){
authAPIcall(
`
query($page: Int){
Page(page: $page,perPage: 20){
reviews(sort:CREATED_AT_DESC${(onlyUser.checked ? ",userId: " + userID : "")}${onlyMedia.checked && onlyMediaResult.id ? ",mediaId: " + onlyMediaResult.id : ""}){
id
createdAt
user{name}
media{
id
type
title{romaji native english}
}
summary
body(asHtml: true)
rating
ratingAmount
}
}
Viewer{unreadNotificationCount}
}`,
{page: npage},
function(data){
buildPage(data.data.Page.reviews.map(review => {
review.type = "TEXT";
review.likes = [];
review.replies = [{
id: review.id,
user: review.user,
likes: [],
text: review.body,
createdAt: review.createdAt
}];
review.text = review.summary
return review
}),"review",requestTime);
handleNotifications(data)
}
);
}
else{
authAPIcall(
`
query($page: Int,$types: [ActivityType]){
Page(page: $page){
activities(${(onlyUser.checked || onlyGlobal.checked ? "" : "isFollowing: true,")}sort: ID_DESC,type_not_in: $types${(onlyReplies.checked ? ",hasReplies: true" : "")}${(onlyUser.checked ? ",userId: " + userID : "")}${(onlyGlobal.checked ? ",hasRepliesOrTypeText: true" : "")}${onlyMedia.checked && onlyMediaResult.id ? ",mediaId: " + onlyMediaResult.id : ""}${date ? ",createdAt_greater: " + (dateToJST(date)/1000) + ",createdAt_lesser: " + (dateToJST(date)/1000 + 24*60*60) : ""}){
... on MessageActivity{
id
type
createdAt
user:messenger{name}
text:message(asHtml: true)
likes{name}
replies{
id
user{name}
likes{name}
text(asHtml: true)
createdAt
}
}
... on TextActivity{
id
type
createdAt
user{name}
text(asHtml: true)
likes{name}
replies{
id
user{name}
likes{name}
text(asHtml: true)
createdAt
}
}
... on ListActivity{
id
type
createdAt
user{name}
status
progress
media{
id
type
title{romaji native english}
}
likes{name}
replies{
id
user{name}
likes{name}
text(asHtml: true)
createdAt
}
}
}
}
Viewer{unreadNotificationCount}
}`,
{page: npage,types:types},
function(data){
buildPage(data.data.Page.activities,"activity",requestTime);
handleNotifications(data)
}
);
}
};
requestPage(page);
let setInputs = function(){
statusInputTitle.style.display = "none";
if(onlyReviews.checked){
inputArea.placeholder = "Writing reviews not supported yet...";
publishButton.innerText = "Publish";
}
else if(onlyForum.checked){
inputArea.placeholder = "Write a forum post...";
statusInputTitle.style.display = "block";
publishButton.innerText = "Publish";
}
else if(onlyUser.checked && onlyUserInput.value && onlyUserInput.value.toLowerCase() !== whoAmI.toLowerCase()){
inputArea.placeholder = "Write a message...";
publishButton.innerText = "Send";
}
else{
inputArea.placeholder = "Write a status...";
publishButton.innerText = "Publish";
}
};
topPrevious.onclick = function(){
loading.innerText = "Loading...";
if(page === 1){
requestPage(1)
}
else{
requestPage(page - 1)
}
};
topNext.onclick = function(){
loading.innerText = "Loading...";
requestPage(page + 1);
};
onlyGlobal.onchange = function(){
loading.innerText = "Loading...";
statusInputTitle.style.display = "none";
inputArea.placeholder = "Write a status...";
onlyUser.checked = false;
onlyForum.checked = false;
onlyReviews.checked = false;
requestPage(1);
};
onlyStatus.onchange = function(){
loading.innerText = "Loading...";
onlyForum.checked = false;
onlyReviews.checked = false;
onlyMedia.checked = false;
requestPage(1);
};
onlyReplies.onchange = function(){
loading.innerText = "Loading...";
onlyReviews.checked = false;
requestPage(1);
};
onlyUser.onchange = function(){
setInputs();
loading.innerText = "Loading...";
onlyGlobal.checked = false;
requestPage(1);
};
onlyForum.onchange = function(){
setInputs();
loading.innerText = "Loading...";
onlyGlobal.checked = false;
onlyStatus.checked = false;
onlyReviews.checked = false;
requestPage(1);
};
onlyMedia.onchange = function(){
setInputs();
loading.innerText = "Loading...";
requestPage(1);
};
onlyReviews.onchange = function(){
setInputs();
onlyGlobal.checked = false;
onlyStatus.checked = false;
onlyForum.checked = false;
onlyReplies.checked = false;
loading.innerText = "Loading...";
requestPage(1);
}
let oldOnlyUser = "";
onlyUserInput.onfocus = function(){
oldOnlyUser = onlyUserInput.value
};
let oldOnlyMedia = "";
onlyMediaInput.onfocus = function(){
oldOnlyMedia = onlyMediaInput.value
};
onlyMediaInput.onblur = function(){
if(onlyMediaInput.value === oldOnlyMedia){
return;
}
if(onlyMediaInput.value === ""){
removeChildren(mediaDisplayResults)
onlyMediaResult.id = false;
}
else{
if(!mediaDisplayResults.childElementCount){
create("span",false,"Searching...",mediaDisplayResults);
}
generalAPIcall(`
query($search: String){
Page(page:1,perPage:5){
media(search:$search,sort:SEARCH_MATCH){
title{romaji}
id
type
}
}
}`,
{search: onlyMediaInput.value},
function(data){
removeChildren(mediaDisplayResults)
data.data.Page.media.forEach((media,index) => {
let result = create("span",["hohSearchResult",media.type.toLowerCase()],media.title.romaji,mediaDisplayResults);
if(index === 0){
result.classList.add("selected");
onlyMediaResult.id = media.id;
onlyMediaResult.type = media.type;
}
result.onclick = function(){
mediaDisplayResults.querySelector(".selected").classList.toggle("selected");
result.classList.add("selected");
onlyMediaResult.id = media.id;
onlyMediaResult.type = media.type;
onlyMedia.checked = true;
onlyStatus.checked = false;
loading.innerText = "Loading...";
requestPage(1);
}
});
if(data.data.Page.media.length){
onlyMedia.checked = true;
onlyStatus.checked = false;
loading.innerText = "Loading...";
requestPage(1);
}
else{
create("span",false,"No results found",mediaDisplayResults);
onlyMediaResult.id = false;
}
}
)
};
};
onlyUserInput.onblur = function(){
if(onlyForum.checked){
inputArea.placeholder = "Write a forum post...";
publishButton.innerText = "Publish";
}
else if(
(onlyUser.checked && onlyUserInput.value && onlyUserInput.value.toLowerCase() !== whoAmI.toLowerCase())
|| (oldOnlyUser !== onlyUserInput.value && onlyUserInput.value !== "")
){
inputArea.placeholder = "Write a message...";
publishButton.innerText = "Send";
}
else{
inputArea.placeholder = "Write a status...";
publishButton.innerText = "Publish";
}
if(oldOnlyUser !== onlyUserInput.value && onlyUserInput.value !== ""){
loading.innerText = "Loading...";
onlyUser.checked = true;
requestPage(1);
}
else if(onlyUser.checked && oldOnlyUser !== onlyUserInput.value){
loading.innerText = "Loading...";
requestPage(1);
}
};
onlyUserInput.addEventListener("keyup",function(event){
if(event.key === "Enter"){
onlyUserInput.blur();
}
});
onlyMediaInput.addEventListener("keyup",function(event){
if(event.key === "Enter"){
onlyMediaInput.blur();
}
});
inputArea.onfocus = function(){
cancelButton.style.display = "inline";
publishButton.style.display = "inline";
};
cancelButton.onclick = function(){
inputArea.value = "";
cancelButton.style.display = "none";
publishButton.style.display = "none";
loading.innerText = "";
onlySpecificActivity = false;
document.activeElement.blur();
};
publishButton.onclick = function(){
if(onlyForum.checked){
alert("Sorry, not implemented yet");
//loading.innerText = "Publishing forum post...";
return;
}
else if(onlyReviews.checked){
alert("Sorry, not implemented yet");
//loading.innerText = "Publishing review...";
return;
}
else if(onlySpecificActivity){
loading.innerText = "Publishing...";
authAPIcall(
"mutation($text: String,$id: Int){SaveTextActivity(id: $id,text: $text){id}}",
{text: inputArea.value,id: onlySpecificActivity},
function(data){
onlySpecificActivity = false;
requestPage(1);
}
);
}
else if(onlyUser.checked && onlyUserInput.value && onlyUserInput.value.toLowerCase() !== whoAmI.toLowerCase()){
loading.innerText = "Sending Message...";
generalAPIcall("query($name:String){User(name:$name){id}}",{name: onlyUserInput.value},function(data){
if(data){
authAPIcall(
"mutation($text: String,$recipientId: Int){SaveMessageActivity(message: $text,recipientId: $recipientId){id}}",
{
text: emojiSanitize(inputArea.value),
recipientId: data.data.User.id
},
function(data){
requestPage(1);
}
)
}
else{
loading.innerText = "Not Found";
}
},"hohIDlookup" + onlyUserInput.value.toLowerCase());
}
else{
loading.innerText = "Publishing...";
authAPIcall(
"mutation($text: String){SaveTextActivity(text: $text){id}}",
{text: emojiSanitize(inputArea.value)},
function(data){
requestPage(1);
}
);
}
inputArea.value = "";
cancelButton.style.display = "none";
publishButton.style.display = "none";
document.activeElement.blur();
};
let sideBarContent = create("div","sidebar",false,feed,"position:absolute;left:20px;top:200px;max-width:150px;");
let buildPreview = function(data){
if(!data){
return;
}
removeChildren(sideBarContent)
let mediaLists = data.data.Page.mediaList.map(mediaList => {
if(aliases.has(mediaList.media.id)){
mediaList.media.title.userPreferred = aliases.get(mediaList.media.id)
}
return mediaList
});
mediaLists.slice(0,20).forEach(mediaList => {
let mediaEntry = create("div",false,false,sideBarContent,"border-bottom: solid;border-bottom-width: 1px;margin-bottom: 10px;border-radius: 3px;padding: 2px;");
create("a","link",mediaList.media.title.userPreferred,mediaEntry,"min-height:40px;display:inline-block;")
.href = "/anime/" + mediaList.media.id + "/" + safeURL(mediaList.media.title.userPreferred);
let progress = create("div",false,false,mediaEntry,"font-size: small;");
create("span",false,"Progress: ",progress);
let number = create("span",false,mediaList.progress + (mediaList.media.episodes ? "/" + mediaList.media.episodes : ""),progress);
let plusProgress = create("span",false,"+",progress,"padding-left:5px;padding-right:5px;cursor:pointer;");
let isBlocked = false;
plusProgress.onclick = function(e){
if(isBlocked){
return
};
if(mediaList.media.episodes){
if(mediaList.progress < mediaList.media.episodes){
mediaList.progress++;
number.innerText = mediaList.progress + (mediaList.media.episodes ? "/" + mediaList.media.episodes : "");
isBlocked = true;
setTimeout(function(){
isBlocked = false;
},300);
if(mediaList.progress === mediaList.media.episodes){
plusProgress.innerText = "";
if(mediaList.status === "REWATCHING"){//don't overwrite the existing end date
authAPIcall(
`mutation($progress: Int,$id: Int){
SaveMediaListEntry(progress: $progress,id:$id,status:COMPLETED){id}
}`,
{id: mediaList.id,progress: mediaList.progress},
data => {}
);
}
else{
authAPIcall(
`mutation($progress: Int,$id: Int,$date:FuzzyDateInput){
SaveMediaListEntry(progress: $progress,id:$id,status:COMPLETED,completedAt:$date){id}
}`,
{
id: mediaList.id,
progress: mediaList.progress,
date: {
year: (new Date()).getUTCFullYear(),
month: (new Date()).getUTCMonth() + 1,
day: (new Date()).getUTCDate(),
}
},
data => {}
);
};
mediaEntry.style.backgroundColor = "rgba(0,200,0,0.1)";
}
else{
authAPIcall(
`mutation($progress: Int,$id: Int){
SaveMediaListEntry(progress: $progress,id:$id){id}
}`,
{id: mediaList.id,progress: mediaList.progress},
data => {}
);
}
localStorage.setItem("hohListPreview",JSON.stringify(data));
}
}
else{
mediaList.progress++;
number.innerText = mediaList.progress + (mediaList.media.episodes ? "/" + mediaList.media.episodes : "");
isBlocked = true;
setTimeout(function(){
isBlocked = false;
},300);
authAPIcall(
`mutation($progress: Int,$id: Int){
SaveMediaListEntry(progress: $progress,id:$id){id}
}`,
{id: mediaList.id,progress: mediaList.progress},
data => {}
);
localStorage.setItem("hohListPreview",JSON.stringify(data));
};
e.stopPropagation();
e.preventDefault();
return false
}
});
};
authAPIcall(
`query($name: String){
Page(page:1){
mediaList(type:ANIME,status_in:[CURRENT,REPEATING],userName:$name,sort:UPDATED_TIME_DESC){
id
priority
scoreRaw: score(format: POINT_100)
progress
status
media{
id
episodes
coverImage{large color}
title{userPreferred}
nextAiringEpisode{episode timeUntilAiring}
}
}
}
}`,{name: whoAmI},function(data){
localStorage.setItem("hohListPreview",JSON.stringify(data));
buildPreview(data,true);
}
);
buildPreview(JSON.parse(localStorage.getItem("hohListPreview")),false);
}
function viewAdvancedScores(url){
let URLstuff = url.match(/^https:\/\/anilist\.co\/user\/(.+)\/(anime|manga)list\/?/);
let name = decodeURIComponent(URLstuff[1]);
generalAPIcall(
`query($name:String!){
User(name:$name){
mediaListOptions{
animeList{advancedScoringEnabled}
mangaList{advancedScoringEnabled}
}
}
}`,
{name: name},function(data){
if(
!(
(URLstuff[2] === "anime" && data.data.User.mediaListOptions.animeList.advancedScoringEnabled)
|| (URLstuff[2] === "manga" && data.data.User.mediaListOptions.mangaList.advancedScoringEnabled)
)
){
return
};
generalAPIcall(
`query($name:String!,$listType:MediaType){
MediaListCollection(userName:$name,type:$listType){
lists{
entries{mediaId advancedScores}
}
}
}`,
{name: name,listType: URLstuff[2].toUpperCase()},
function(data2){
let list = new Map(returnList(data2,true).map(a => [a.mediaId,a.advancedScores]));
let finder = function(){
if(!document.URL.match(/^https:\/\/anilist\.co\/user\/(.+)\/(anime|manga)list\/?/)){
return
};
document.querySelectorAll(
".list-entries .entry .title > a:not(.hohAdvanced)"
).forEach(function(entry){
entry.classList.add("hohAdvanced");
let key = parseInt(entry.href.match(/\/(\d+)\//)[1]);
let dollar = create("span","hohAdvancedDollar","$",entry.parentNode);
let advanced = list.get(key);
let reasonable = Object.keys(advanced).map(
key => [key,advanced[key]]
).filter(
a => a[1]
);
dollar.title = reasonable.map(
a => a[0] + ": " + a[1]
).join("\n");
if(!reasonable.length){
dollar.style.display = "none"
}
});
setTimeout(finder,1000);
};finder();
}
)
})
};
if(useScripts.webmResize){
setInterval(function(){
document.querySelectorAll("source").forEach(video => {
let hashMatch = (video.src || "").match(/#\d+(\.\d+)?%?$/);
if(hashMatch && !video.parentNode.width){
video.parentNode.setAttribute("width",hashMatch[0].substring(1))
}
})
},500)
}
exportModule({
id: "webmResize",
description: "Resize videos with a width in the URL hash (like #220 or #40%)",
isDefault: true,
categories: ["Feeds","Newly Added"],
visible: true
})
function yearStepper(){
if(!location.pathname.match(/\/user\/.*\/(anime|manga)list/)){
return
}
let slider = document.querySelector(".el-slider");
if(!slider){
setTimeout(yearStepper,200);
return
};
const maxYear = parseInt(slider.getAttribute("aria-valuemax"));
const minYear = parseInt(slider.getAttribute("aria-valuemin"));
const yearRange = maxYear - minYear;
let clickSlider = function(year){//thanks, mator!
let runway = slider.children[0];
let r = runway.getBoundingClientRect();
const x = r.left + r.width * ((year - minYear) / yearRange);
const y = r.top + r.height / 2;
runway.dispatchEvent(new MouseEvent("click",{
clientX: x,
clientY: y
}))
};
let adjuster = function(delta){
let heading = slider.previousElementSibling;
if(heading.children.length === 0){
if(delta === -1){
clickSlider(maxYear)
}
else{
clickSlider(minYear)
}
}
else{
let current = parseInt(heading.children[0].innerText);
clickSlider(current + delta);
}
};
if(document.querySelector(".hohStepper")){
return
};
slider.style.position = "relative";
let decButton = create("span","hohStepper","<",slider,"left:-27px;font-size:200%;top:0px;");
let incButton = create("span","hohStepper",">",slider,"right:-27px;font-size:200%;top:0px;");
decButton.onclick = function(){
adjuster(-1)
};
incButton.onclick = function(){
adjuster(1)
}
}
if(useScripts.youtubeFullscreen){
setInterval(function(){
document.querySelectorAll(".youtube iframe").forEach(video => {
if(!video.hasAttribute("allowfullscreen")){
video.setAttribute("allowfullscreen","true")
}
})
},1000)
}
exportModule({
id: "youtubeFullscreen",
description: "Allow Youtube videos to play in fullscreen mode",
isDefault: false,
categories: ["Script"],
visible: true
})
//create your own module
//make a javascript file, called yourModule.js, in the directory "modules"
//include the following code:
exportModule({
id: "howto",//an unique identified for your module
description: "what your module does",
extendedDescription: `
A long description of what your module does.
This appears when people click the "more info" icon (🛈) on the settings page.
`,
isDefault: false,
importance: 0,//a number, which determines the order of the settings page. Higher numbers are more important. Leave it as 0 if unsure.
categories: ["Script"],//what categories your module belongs in
//Notifications, Feeds, Forum, Lists, Profiles, Stats, Media, Navigation, Browse, Script, Login, Newly Added
visible: false,//if the module should be visible in the settings
urlMatch: function(url,oldUrl){//a function that returns true when on the parts of the site you want it to run. url is the current url, oldUrl is the previous page
//example: return url === "https://anilist.co/reviews"
return false;
},
code: function(){
//your code goes here
}
})
//your module can also have extra code and utility functions
})()
//Automail built at 1589394927