// 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);
}
// 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?
if(!flag){// When we add a flag to our selection, save it for when we reload the page.
nsetup.save();
saveFlags();
}
},
init:function(){
}
/** Create flag button and initialise our selected flags */
functioninit(){
letflagsForm=createAndAssign('div',{
className:'flagsForm',
innerHTML:nsetup.form
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>'
});
// Where do we append the flagsForm to?
@ -206,20 +158,57 @@ const software = {
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 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.');
// 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.
console.log('[BantFlags] Could not fetch flags, status: '+resp.status);
console.log(resp.statusText);
setTimeout(func,requestRetryInterval);
}
// 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?
if(!flag){// When we add a flag to our selection, save it for when we reload the page.
nsetup.save();
saveFlags();
}
},
init:function(){
}
/** Create flag button and initialise our selected flags */
functioninit(){
letflagsForm=createAndAssign('div',{
className:'flagsForm',
innerHTML:nsetup.form
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>'
});
// Where do we append the flagsForm to?
@ -203,16 +158,53 @@ var nsetup = { // not anymore a clone of the original setup
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) {