User:Shisma/userscript-knowyourmeme.js
Note: After publishing, you may have to bypass your browser's cache to see the changes.
- Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
- Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
- Internet Explorer / Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5
- Opera: Press Ctrl-F5.
// ==UserScript==
// @name Update URL with Meme ID
// @namespace http://tampermonkey.net/
// @version 0.1
// @description Extract meme ID and update URL on Know Your Meme
// @author User:Shisma
// @match https://knowyourmeme.com/memes/**
// @grant none
// ==/UserScript==
(function() {
'use strict';
// Function to extract meme ID and update URL
const updateURLWithMemeId = () => {
// Query for the favorite link that contains the meme ID
const favoriteLink = document.querySelector('a.favorite[data-item-id]');
if (favoriteLink) {
const memeId = favoriteLink.getAttribute('data-item-id');
if (memeId) {
const newUrl = `https://knowyourmeme.com/memes/${memeId}`;
// Update the URL without creating a new history entry
window.history.replaceState({}, '', newUrl);
console.log('URL updated to include Meme ID:', newUrl);
}
}
};
updateURLWithMemeId();
})();