// This is kinda necessary but I don't know how much. Can I just wrap checking regions on startup or is the whole script required? I won't be testing that for now.
console.log('[BantFlags] Could not fetch flags, status: '+resp.status);
console.log(resp.statusText);
setTimeout(func,requestRetryInterval);
if(!flag){// When we add a flag to our selection, save it for when we reload the page.
saveFlags();
}
}
// TODO: this shouldn't be a object.
varnsetup={// not anymore a clone of the original setup
namespace:'BintFlegs',// TODO: should be const.
flagsLoaded:false,
form:'<span id="bantflags_container"></span><button type="button" id="append_flag_button" title="Click to add selected flag to your flags. Click on flags to remove them. Saving happens automatically, you only need to refresh the pages that have an outdated flaglist on the page."><<</button><button id="flagLoad" type="button">Click to load flags.</button><div id="flagSelect" ><ul class="hide"></ul><input type="button" value="(You)" onclick=""></div>',
fillHtml:function(){// TODO: this function should have a better name. Only called by nsetup.init, can be inlined?
/** Create flag button and initialise our selected flags */
functioninit(){
letflagsForm=createAndAssign('div',{
className:'flagsForm',
innerHTML:'<span id="bantflags_container"></span><button type="button" id="append_flag_button" title="Click to add selected flag to your flags. Click on flags to remove them. Saving happens automatically, you only need to refresh the pages that have an outdated flaglist on the page."><<</button><button id="flagLoad" type="button">Click to load flags.</button><div id="flagSelect" ><ul class="hide"></ul><input type="button" value="(You)" onclick=""></div>'
if(software.nodegucaDoushio){document.querySelector('section').append(flagsForm);}// As posts are added the flagForm moves up the page. Could we append this after .section?
if(software.nodegucaDoushio){document.querySelector('section').append(flagsForm);}// As posts are added the flagForm moves up the page. Could we append this after .section?
console.log('[bantflags] Couldn\'t load flags. Refresh the page.');
return;
}
);
}
loadFlags(resp);
}
);
}
// This one await is what stops regular bantflags from working with GM4 lole.
regions=awaitGM.getValue(nsetup.namespace);
if(!regions){// No flags set.
(async()=>{// This one await is why we need a seperate script ;_;
regions=awaitGM.getValue(namespace);
if(!regions){// Should only be called before you set flags for the first time.
regions=[];
window.confirm('[BantFlags]: No Flags detected.');
window.confirm('[BantFlags]: No Flags detected.\nIf this is your first time running bantflags, look for the "Click to load flags." button at the bottom right of the thread, then select your flag and press the ">>" button.');
letlastPosts=postsContainer.slice(Math.max(postsContainer.length-evDetail.count,1));//get the last n elements (where n is evDetail.count)
lastPosts.forEach(function(post_container){
varpost_nr=post_container.id.replace('pc','');
postNrs.push(post_nr);
});
lastPosts.forEach(function(post_container){
varpost_nr=post_container.id.replace('pc','');
postNrs.push(post_nr);
});
resolveRefFlags();
},false);
resolveFlags();
},false);
}
nsetup.init();
}
if(software.nodegucaDoushio){
// This is poking at the mutations made on the page to figure out what happened and thus what actions to take.
// There is full support for nodeguca but I don't have a Doushio board I feel comfortable spamming to ensure it works properly there. There is at least partial support.
newMutationObserver(function(mutations){
mutations.forEach(function(mutation){
if(mutation.addedNodes.length>0){// A post was added.
// This is poking at the mutations made on the page to figure out what happened and thus what actions to take.
// There is full support for nodeguca but I don't have a Doushio board I feel comfortable spamming to ensure it works properly there. There is at least partial support.
newMutationObserver(function(mutations){
mutations.forEach(function(mutation){
if(mutation.addedNodes.length>0){// A post was added.
varnsetup={// not anymore a clone of the original setup
namespace:'BintFlegs',// TODO: should be const.
flagsLoaded:false,
form:'<span id="bantflags_container"></span><button type="button" id="append_flag_button" title="Click to add selected flag to your flags. Click on flags to remove them. Saving happens automatically, you only need to refresh the pages that have an outdated flaglist on the page."><<</button><button id="flagLoad" type="button">Click to load flags.</button><div id="flagSelect" ><ul class="hide"></ul><input type="button" value="(You)" onclick=""></div>',
fillHtml:function(){// TODO: this function should have a better name. Only called by nsetup.init, can be inlined?
/** Create flag button and initialise our selected flags */
functioninit(){
letflagsForm=createAndAssign('div',{
className:'flagsForm',
innerHTML:'<span id="bantflags_container"></span><button type="button" id="append_flag_button" title="Click to add selected flag to your flags. Click on flags to remove them. Saving happens automatically, you only need to refresh the pages that have an outdated flaglist on the page."><<</button><button id="flagLoad" type="button">Click to load flags.</button><div id="flagSelect" ><ul class="hide"></ul><input type="button" value="(You)" onclick=""></div>'
if(software.nodegucaDoushio){document.querySelector('section').append(flagsForm);}// As posts are added the flagForm moves up the page. Could we append this after .section?
for(vari=0;i<selectedFlags.length;i++){
storedFlags[i]=selectedFlags[i].title;
}
for(variinregions){
setFlag(regions[i]);
}
GM_setValue(nsetup.namespace,storedFlags);
regions=GM_getValue(nsetup.namespace);// TODO: this could be selectedFlags? GM_getValue is expensive.
if(software.nodegucaDoushio){document.querySelector('section').append(flagsForm);}// As posts are added the flagForm moves up the page. Could we append this after .section?
console.log('[bantflags] Couldn\'t load flags. Refresh the page.');
return;
}
onFlagsLoad(resp);
loadFlags(resp);
}
);
}
// This should only happen before you set flags for the first time.
regions=GM_getValue(nsetup.namespace);
if(!regions){
regions=GM_getValue(namespace);
if(!regions){// Should only be called before you set flags for the first time.
regions=[];
window.confirm('[BantFlags]: No Flags detected.');
window.confirm('[BantFlags]: No Flags detected.\nIf this is your first time running bantflags, look for the "Click to load flags." button at the bottom right of the thread, then select your flag and press the ">>" button.');
// This is poking at the mutations made on the page to figure out what happened and thus what actions to take.
// There is full support for nodeguca but I don't have a Doushio board I feel comfortable spamming to ensure it works properly there. There is at least partial support.
newMutationObserver(function(mutations){
@ -389,27 +378,27 @@ if (software.nodegucaDoushio) {