Content deleted Content added
←Created page with '== Minified and personalised == {{ping|FlightTime}} Here is a version of the script that will hopefully meet your desires: <syntaxhighlight lang="js"> $(() => {...' |
FlightTime (talk | contribs) →Minified and personalised: Update to current version |
||
(10 intermediate revisions by 2 users not shown) | |||
Line 2:
{{ping|FlightTime}} Here is a version of the script that will hopefully meet your desires:
<syntaxhighlight lang="js">
// <nowiki>
$(() =>
{
Line 8 ⟶ 10:
if(!logout) return;
// Create new logout link.
var new_logout = document.createElement("a");
new_logout.innerText = logout.innerText;
// Insert new logout link and remove old.
logout.insertAdjacentElement("afterend", new_logout);
logout.remove();
// Get user-defined styling.
var fw = window.us_conlog_font_weight ? window.us_conlog_font_weight : "bold";
document.getElementsByTagName("body")[0].insertAdjacentHTML("afterbegin", "<div id='use_conlog'></div>");▼
var fs = window.us_conlog_font_size ? window.us_conlog_font_size : "86%";
var bg = window.us_conlog_background ? window.us_conlog_background : "#EEE";
var fg = window.us_conlog_color ? window.us_conlog_color : "#000";
var bd = window.us_conlog_border ? window.us_conlog_border : "2px solid #00F";
// Add styling to the page.
var conlog = document.getElementById("use_conlog");▼
document.getElementsByTagName("body")[0].insertAdjacentHTML("afterbegin",
"<style>#use-conlog button { margin: 0 0.2em; border-radius: 9em; padding: 0 0.7em; box-sizing: border-box;" +
`font-weight: ${fw}; font-size: ${fs}; background: ${bg}; color: ${fg}; border: ${bd}}` +
"#use-conlog button:active { background:rgba(255,255,255,0.6)}</style>");
// Main grouping div for conlog elements.
▲ document.getElementsByTagName("body")[0].insertAdjacentHTML("afterbegin", "<div id='
new_logout.addEventListener("click", event =>
{
// Create the logout confirmation prompt.
conlog.insertAdjacentHTML("beforeend",
"<div onclick='this.style.transform = \"translateY(-130%)\";setTimeout(function(){this.remove()}.bind(this), 500);' style='" +
"position:fixed; top:0; left:0; right:0; margin: 0 0 auto 0; height: auto; line-height: 1.4em; " +
"padding: 0.6em 2em; opacity: 1; text-align: center; z-index: 9999
"
"<div style='margin-bottom: 0.5em;'>You clicked on a log-out link. Do you want to continue?</div>" +
"<div><button>No</button><button
);
// Logout handler.
document.getElementById("conlog-logout").addEventListener("click", event =>
{
new mw.Api().post(
{
"action": "logout",
"token": mw.user.tokens.get("csrfToken")
})
.fail(result => { mw.notify("Failed to log out: " + result); })
.done(() => { window.___location.href = mw.util.getUrl(mw.config.get("wgPageName")); });
});
// The logout confirmation prompt pops down from the top.
setTimeout(() => {
event.preventDefault();
Line 38 ⟶ 66:
});
});
// </nowiki>
</syntaxhighlight>
Let me know if something doesn't work as expected. Regards, <span style="font-family:cursive;color:blue">—[[User:Guywan|guywan]] ([[User talk:Guywan|talk]] • [[Special:Contributions/Guywan|contribs]])</span> 18:45, 21 March 2020 (UTC)
:{{re|Guywan}} Oh my gosh, Thank you. I'll check it out right now. Wow its like Christmas :) - <span style="font-family:Trebuchet MS">[[User:FlightTime|<span style="color:#800000">'''FlightTime'''</span>]] <small>([[User talk:FlightTime|<span style="color:#FFD700">'''open channel'''</span>]])</small></span> 18:53, 21 March 2020 (UTC)
::{{re|Guywan}} Seems to work just fine. Again thank you very much :) - <span style="font-family:Trebuchet MS">[[User:FlightTime|<span style="color:#800000">'''FlightTime'''</span>]] <small>([[User talk:FlightTime|<span style="color:#FFD700">'''open channel'''</span>]])</small></span> 19:01, 21 March 2020 (UTC)
{{ping|FlightTime}} Hello again, I've made some small changes to [[User:Guywan/Scripts/ConfirmLogout.js|my version]]. Most noticeably, you are logged out immediately instead of being taken to [[Special:Logout]]. If you are interested in this, the easiest thing to do would be to replace your [[User:FlightTime/vector.js|vector.js]] with this:
<syntaxhighlight lang="js">
us_conlog_background = "#EEE";
us_conlog_border = "2px solid #00F";
mw.loader.getScript("/w/index.php?title=User:Guywan/Scripts/ConfirmLogout.js&action=raw&ctype=text/javascript");//[[User:Guywan/Scripts/ConfirmLogout.js]]
</syntaxhighlight>
Regards, <span style="font-family:cursive;color:blue">—[[User:Guywan|guywan]] ([[User talk:Guywan|talk]] • [[Special:Contributions/Guywan|contribs]])</span> 19:28, 22 March 2020 (UTC)
:{{re|Guywan}} Thank you, that was one thing I found a little annoying and was going to ask if it could be removed, but I don't want to wear out my welcome. You have a great day. Cheers, - <span style="font-family:Trebuchet MS">[[User:FlightTime|<span style="color:#800000">'''FlightTime'''</span>]] <small>([[User talk:FlightTime|<span style="color:#FFD700">'''open channel'''</span>]])</small></span> 19:39, 22 March 2020 (UTC)
::{{re|Guywan}} Could you show the patch for this and where to place it, I also use this script on Commons. I think it would be better for me to adjust my script here so I can keep my Commons version the same. Thanx again, - <span style="font-family:Trebuchet MS">[[User:FlightTime|<span style="color:#800000">'''FlightTime'''</span>]] <small>([[User talk:FlightTime|<span style="color:#FFD700">'''open channel'''</span>]])</small></span> 20:04, 22 March 2020 (UTC)
::: {{ping|FlightTime}} You can import the script globally from meta. Add this to [[meta:User:FlightTime/global.js]]:
<syntaxhighlight lang="js">
us_conlog_background = "#EEE";
us_conlog_border = "2px solid #00F";
mw.loader.load("https://en.wikipedia.org/w/index.php?title=User:Guywan/Scripts/ConfirmLogout.js&action=raw&ctype=text/javascript");
</syntaxhighlight>
::: Then you'll need to remove local imports, I think. Let me know if you'd rather have local versions. <span style="font-family:cursive;color:blue">—[[User:Guywan|guywan]] ([[User talk:Guywan|talk]] • [[Special:Contributions/Guywan|contribs]])</span> 20:21, 22 March 2020 (UTC)
|