Commit 031dfa88 authored by Pierre M's avatar Pierre M
Browse files

make plonking of closed accounts optional


automatically delete closed accounts from the plonk list
Signed-off-by: Pierre M's avatarPierre Mazière <pierre.maziere@gmx.com>
parent b937335b
2016-05-26 v3
make plonking of closed accounts optional
automatically delete closed accounts from the plonk list
2016-05-26 v2
add a UI to manage the plonk list
......
......@@ -2,7 +2,7 @@
// @name DLFPlonk
// @namespace DLFPlonk
// @include https://linuxfr.org/*
// @version 2
// @version 3
// @grant GM_xmlhttpRequest
// @grant GM_getValue
// @grant GM_setValue
......@@ -19,12 +19,13 @@
(function() {
let plonkList = GM_getValue("plonkList","").split(",");
if(plonkList.length === 1 && plonkList[0] === ""){
plonkList=[];
plonkList = [];
}
let plonkClosedAccounts = GM_getValue("plonkClosedAccounts",true);
GM_addStyle(".overlaybg{position:fixed;top:0;left:0;width: 100%;height: 100%;background-color:#000; opacity:0.5;z-index:100}");
GM_addStyle(".overlaywin{position:fixed;left:0;right:0;top:0;bottom:0;width:600px;height:300px;margin:auto;background-color:#FFF;z-index:101;padding:10px 20px;border:thick double #000}");
GM_addStyle(".overlaywin select{width:100%;height:200px}");
GM_addStyle(".overlaywin select{width:100%;height:180px}");
GM_addStyle(".overlaywin button{background-image:none;padding-left:5px}");
GM_addStyle(".overlaywin button[disabled='disabled']{background-image:none;padding-left:5px;color:gray}");
......@@ -50,13 +51,27 @@
}else{
p.appendChild(document.createTextNode("Aucun utilisateur plonké pour le moment."));
select.remove();
select=null;
select = null;
}
form.appendChild(p);
if(select){
form.appendChild(select);
}
let checkbox = document.createElement("input");
checkbox.setAttribute("type","checkbox");
checkbox.setAttribute("id","closedAccounts");
checkbox.addEventListener("change",function(){plonkClosedAccounts=!plonkClosedAccounts; GM_setValue("plonkClosedAccounts",plonkClosedAccounts);});
if(plonkClosedAccounts){
checkbox.setAttribute("checked","checked");
}
let label = document.createElement("label");
label.appendChild(checkbox);
label.appendChild(document.createTextNode("plonker les comptes fermés."));
let div = document.createElement("div");
div.appendChild(label);
form.appendChild(div);
let addButton = document.createElement("button");
addButton.setAttribute("id","plonkAdd");
addButton.appendChild(document.createTextNode("Plonker '"+user+"'"));
......@@ -147,20 +162,41 @@
let txt = document.createTextNode(" Plonk");
a.appendChild(txt);
a.addEventListener("click",function(){addToPlonkList(plonkList,userLink.textContent);},true);
a.href="#";
a.href = "#";
sup.appendChild(a);
span.appendChild(sup);
userLink.parentNode.insertBefore(span,userLink.nextSibling);
GM_xmlhttpRequest({
method: "GET",
url: userLink.href,
context: articles[i],
onload: function(response) {
if(response.responseText.match(/Compte fermé/)){
response.context.style.display="none";
if(plonkClosedAccounts){
GM_xmlhttpRequest({
method: "GET",
url: userLink.href,
context: articles[i],
onload: function(response) {
if(response.responseText.match(/Compte fermé/)){
response.context.style.display = "none";
let userLink =response.context.getElementsByClassName('meta').item(0).getElementsByTagName('a').item(0);
let listModified = false;
let index = plonkList.indexOf(userLink.textContent);
if(index !== -1){
plonkList.splice(index,1);
listModified = true;
}
let re = new RegExp("https://linuxfr.org/users/(.*)$");
let matches = userLink.href.match(re);
if(matches !== null){
index = plonkList.indexOf(matches[1]);
if(index !== -1){
plonkList.splice(index,1);
listModified = true;
}
}
if(listModified){
GM_setValue("plonkList",plonkList.join(","));
}
}
}
}
});
});
}
for(let j = 0; j < plonkList.length; j++){
if (userLink.textContent === plonkList[j] || userLink.href === "https://linuxfr.org/users/"+plonkList[j]){
articles[i].style.display = "none";
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment