Wikipedia talk:WikiProject User scripts/Scripts/WikiBreak Enforcer/script.js
Protocol-relative
editThis edit request has been answered. Set the |answered= or |ans= parameter to no to reactivate your request. |
Hello. This line:
location = "http://"+location.host+"/w/index.php?title="
+ "Special:Userlogout&returnto=Main_Page";
should probably be changed to:
location = "//"+location.host+"/w/index.php?title="
+ "Special:Userlogout&returnto=Main_Page";
so that it works in HTTPS (secure protocol). Thanks, πr2 (t • c) 04:14, 9 December 2012 (UTC)
- Done -- DQ (ʞlɐʇ) 05:25, 19 December 2012 (UTC)
Protected edit request on 4 March 2014
editThis edit request has been answered. Set the |answered= or |ans= parameter to no to reactivate your request. |
Since addOnloadHook
has been deprecated, should we change it to $(document).ready
? Thanks!
Chmarkine (talk) 05:26, 4 March 2014 (UTC)
- Done, Chmarkine. Please confirm that I did what you wanted, and ping me if I made a mistake. Nyttend (talk) 13:40, 4 March 2014 (UTC)
Pedantic protected edit request
editThis edit request has been answered. Set the |answered= or |ans= parameter to no to reactivate your request. |
A bit of pedantry, but I'd prefer to see the leading zero example changed to 09 rather than 07. octal 7 == decimal 7, so technically the 07 example isn't much of a problem, but 09 would be. Martijn Hoekstra (talk) 16:03, 19 January 2015 (UTC)
- Done --Redrose64 (talk) 23:14, 19 January 2015 (UTC)
Created Sandbox Page
editI created a sandbox page for this script. See Wikipedia:WikiProject User scripts/Scripts/WikiBreak Enforcer/script/sandbox.
UpsandDowns1234 16:08, 16 March 2017 (UTC)
Topicon
editThis edit request to Wikipedia:WikiProject User scripts/Scripts/WikiBreak Enforcer/script has been answered. Set the |answered= or |ans= parameter to no to reactivate your request. |
Please add the topicon to the page UpsandDowns1234 15:32, 23 March 2017 (UTC)
- @UpsandDowns1234: Which topicon ? could you make the description a bit more elaborate? —TheDJ (talk • contribs)
- @TheDJ: The fully protected topicon. UpsandDowns1234 16:19, 23 March 2017 (UTC)
- @UpsandDowns1234: Which topicon ? could you make the description a bit more elaborate? —TheDJ (talk • contribs)
- In addition, @TheDJ:, would this and other pages be suitable for the JS content model? Jo-Jo Eumerus (talk, contributions) 15:43, 23 March 2017 (UTC)
- I've changed the content model of the sandbox. I guess it could be done.. Give me some time to think it through definitively :) —TheDJ (talk • contribs) 16:00, 23 March 2017 (UTC)
@TheDJ: would you mind responding to this request please? — Martin (MSGJ · talk) 08:05, 28 March 2017 (UTC)
Making the enforcer a function?
editIt would be more useful if you made the script a function. Then all you would have to do is call the function to enforce the wikibreak. Here is the function:
function wikiBreakEnforcer(yr, mth, dy, h, m, s) {
/*** BEGIN WIKIBREAK ENFORCER ***/
var date = { year: yr, month: mth, day: dy};
var time = { hours: h, minutes: m, seconds: s };
var currentDate = new Date();
var enforcedBreakEnd = new Date(
date.year,date.month-1,date.day,time.hours,time.minutes,time.seconds);
if (currentDate <= enforcedBreakEnd) {
alert("Enforced wikibreak until "+enforcedBreakEnd.toLocaleString()
+ "\n(now is "+currentDate.toLocaleString()+")\n\nBye!");
}
/*** END WIKIBREAK ENFORCER ***/
}
No need to edit, all that needs to happen is the script imported and the function called. Much cleaner, huh? All that needs to be typed:
importScript("wikibreakenforcer.js");
wikiBreakEnforcer(2017, 3, 27, 0, 0, 0);
Is it possible that an administrator makes that happen? UpsandDowns1234 (Talk to me) (My Contribs) 06:31, 16 April 2017 (UTC)
Protected edit request on 6 February 2020
editThis edit request to Wikipedia:WikiProject User scripts/Scripts/WikiBreak Enforcer/script has been answered. Set the |answered= or |ans= parameter to no to reactivate your request. |
Please replace
location = "//"+location.host+"/w/index.php?title="
+ "Special:Userlogout&returnto=Main_Page";
with
$('#pt-logout a').click();
This fixes the bug reported here. Basically, the thing is that MW changed (phab:T25227 I think) such that navigating to that URL no longer causes a log out (rather it just leads to a confirmation page). Simulating a click on the log out button (present across all skins) uses javascript to force a log out. This change has been tested. SD0001 (talk) 11:53, 6 February 2020 (UTC)
- @SD0001: For me, in Firefox with Monobook, the suggested change doesn't work, either: it simply provides a popup dialog confirming the logout, which can be canceled to allow normal editing (though it might reappear on every page load). We'll likely need to directly invoke the logout API call. Writ Keeper ⚇♔ 16:09, 10 February 2020 (UTC)
- I've applied a change to the script to call the API, rather than messing around with redirects or simulated clicks (although there is still a redirect to the login page once the logout process is complete). Writ Keeper ⚇♔ 18:13, 10 February 2020 (UTC)
Protected edit request on 10 February 2020
editThis edit request has been answered. Set the |answered= or |ans= parameter to no to reactivate your request. |
Remove <syntaxhighlight lang=javascript>
(and </syntaxhighlight>); it is not necessary when the content model is JavaScript. * Pppery * it has begun... 22:00, 10 February 2020 (UTC)