Logout links

by math_explorer, Nov 30, 2014, 4:25 AM

All in a day's procrastination.

(Yes, these are logout links. You probably don't want to click them.)
Easy
Garbage
DOES UPPERCASE WORK? (the answer is no)
s/o/%6f/g

// ==UserScript==
// @name        AoPS Logout Guard
// @namespace   math_explorer
// @include     *artofproblemsolving*
// @version     1
// @grant       none
// ==/UserScript==
 
var ts = document.getElementsByTagName('a');
for (var i = 0; i < ts.length; i++){
    var t = ts[i];
    if (decodeURI(t.href).match(/logout/) && t.parentNode.id !== 'top-actions') {
        var s = t.href;
        if (s.length >= 24) s = "..." + s.substr(s.length - 20, 20);
        var newElt = content.document.createElement('span');
        newElt.textContent = "[LOGOUT? " + s + "]";
        newElt.style.verticalAlign = 'sub';
        newElt.style.backgroundColor = '#f00';
        newElt.style.color = '#fff';
        newElt.style.fontSize = '75%';
        t.appendChild(newElt);
    }
}
This post has been edited 1 time. Last edited by math_explorer, Nov 30, 2014, 4:29 AM

Comment

3 Comments

The post below has been deleted. Click to close.
This post has been deleted. Click here to see post.
Improved version:

// ==UserScript==
// @name        AoPS Logout Guard
// @namespace   math_explorer
// @include     *artofproblemsolving*
// @version     1.1
// @grant       none
// ==/UserScript==
 
var ts = document.getElementsByTagName('a');
for (var i = 0; i < ts.length; i++){
  var t = ts[i];
  if (/mode=logout/.test(decodeURI(t.href)) && t.parentNode.id !== 'top-actions') {
    var s = t.href;
    if (s.length >= 24) s = "..." + s.substr(s.length - 20, 20);
    var newElt = content.document.createElement('span');
    newElt.textContent = "[LOGOUT? " + s + "]";
    newElt.style.verticalAlign = 'sub';
    newElt.style.backgroundColor = '#f00';
    newElt.style.color = '#fff';
    newElt.style.fontSize = '75%';
    t.appendChild(newElt);
  }
}


Improvements:
  • Changed regex to strictly match mode=logout (I was having problems with perfectly OK links that contained the word "logout" in them)
  • Changed String.match(regex) to RegExp.test(str)

by NeoMathematicalKid, Dec 1, 2014, 1:07 AM

The post below has been deleted. Click to close.
This post has been deleted. Click here to see post.
I thought about how specific to make the regex, but couldn't think of any false positive "logout" links. Are there a lot?

by math_explorer, Dec 1, 2014, 3:53 AM

The post below has been deleted. Click to close.
This post has been deleted. Click here to see post.
Well, if you search for the string "logout", then yes. Of course, it's not like anyone would, but if someone links to a website whose address contains the string "logout", then the script would activate.

by NeoMathematicalKid, Dec 1, 2014, 1:30 PM

♪ i just hope you understand / sometimes the clothes do not make the man ♫ // https://beta.vero.site/

avatar

math_explorer
Archives
+ September 2019
+ February 2018
+ December 2017
+ September 2017
+ July 2017
+ March 2017
+ January 2017
+ November 2016
+ October 2016
+ August 2016
+ February 2016
+ January 2016
+ September 2015
+ July 2015
+ June 2015
+ January 2015
+ July 2014
+ June 2014
inv
+ April 2014
+ December 2013
+ November 2013
+ September 2013
+ February 2013
+ April 2012
Shouts
Submit
  • how do you have so many posts

    by krithikrokcs, Jul 14, 2023, 6:20 PM

  • lol⠀⠀⠀⠀⠀

    by math_explorer, Jan 20, 2021, 8:43 AM

  • woah ancient blog

    by suvamkonar, Jan 20, 2021, 4:14 AM

  • https://artofproblemsolving.com/community/c47h361466

    by math_explorer, Jun 10, 2020, 1:20 AM

  • when did the first greed control game start?

    by piphi, May 30, 2020, 1:08 AM

  • ok..........

    by asdf334, Sep 10, 2019, 3:48 PM

  • There is one existing way to obtain contributorship documented on this blog. See if you can find it.

    by math_explorer, Sep 10, 2019, 2:03 PM

  • SO MANY VIEWS!!!
    PLEASE CONTRIB
    :)

    by asdf334, Sep 10, 2019, 1:58 PM

  • Hullo bye

    by AnArtist, Jan 15, 2019, 8:59 AM

  • Hullo bye

    by tastymath75025, Nov 22, 2018, 9:08 PM

  • Hullo bye

    by Kayak, Jul 22, 2018, 1:29 PM

  • It's sad; the blog is still active but not really ;-;

    by GeneralCobra19, Sep 21, 2017, 1:09 AM

  • dope css

    by zxcv1337, Mar 27, 2017, 4:44 AM

  • nice blog ^_^

    by chezbgone, Mar 28, 2016, 5:18 AM

  • shouts make blogs happier

    by briantix, Mar 18, 2016, 9:58 PM

91 shouts
Contributors
Tags
About Owner
  • Posts: 583
  • Joined: Dec 16, 2006
Blog Stats
  • Blog created: May 17, 2010
  • Total entries: 327
  • Total visits: 354197
  • Total comments: 368
Search Blog
a