Skip to content

Instantly share code, notes, and snippets.

@akinov
Last active February 17, 2021 16:47
Show Gist options
  • Save akinov/95cf1c427ce26198a5bfc9c6b70ec109 to your computer and use it in GitHub Desktop.
Save akinov/95cf1c427ce26198a5bfc9c6b70ec109 to your computer and use it in GitHub Desktop.
// ==UserScript==
// @name messenger ninja
// @namespace https://gist.github.com/akinov/95cf1c427ce26198a5bfc9c6b70ec109
// @version 0.1
// @description ninja!
// @author akinov
// @grant none
// @match https://www.messenger.com/*
/* load jQuery */
// @require https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js
// ==/UserScript==
(function() {
'use strict';
const nekoSrc = 'https://pbs.twimg.com/profile_images/424484505915621376/EOwsjaMZ_400x400.png',
nekoName = '猫田 猫男';
const $toggeBtn = $('<div>🎭</div>').css({
position: 'fixed',
right: '10px',
bottom: '10px',
'z-index': '1000'
}).on('click', toggleNinja);
$('body').append($toggeBtn);
function toggleNinja() {
$('._1t2u ._4ld- > img, ._1t2u ._1jt6 img, .uiScrollableAreaContent ._55lt img').each(function() {
const $this = $(this);
if (!$this.attr('origin-src')) {
$this.attr('origin-src', $this.attr('src'));
}
toggleImg($this);
});
$('._3oh- a, .uiScrollableAreaContent ._1ht6').each(function() {
const $this = $(this);
if (!$this.attr('origin-text')) {
$this.attr('origin-text', $this.text());
}
toggleText($this);
});
}
function toggleImg($this) {
if ($this.attr('origin-src') == $this.attr('src')) {
$this.attr('src', nekoSrc);
} else {
$this.attr('src', $this.attr('origin-src'));
}
}
function toggleText($this) {
if ($this.attr('origin-text') == $this.text()) {
$this.text(nekoName);
} else {
$this.text($this.attr('origin-text'));
}
}
})();
@Korb
Copy link

Korb commented Feb 17, 2021

What exactly does this script do?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment