|
// ==UserScript== |
|
// @name Murdle Simple Shares |
|
// @namespace https://gist.github.com/q00u |
|
// @downloadURL https://gist.github.com/q00u/c7fda688902346fc672f9870957d05d1/raw/MurdleSimpleShare.user.js |
|
// @updateURL https://gist.github.com/q00u/c7fda688902346fc672f9870957d05d1/raw/MurdleSimpleShare.user.js |
|
// @supportURL https://gist.github.com/q00u/c7fda688902346fc672f9870957d05d1 |
|
// @version 0.0.4 |
|
// @description Smaller shares for those with longer Murdle streaks! |
|
// @author Phoenix G |
|
// @match https://murdle.com/ |
|
// @icon https://www.google.com/s2/favicons?sz=64&domain=murdle.com |
|
// @grant none |
|
// ==/UserScript== |
|
|
|
(function() { |
|
'use strict'; |
|
|
|
function newShortSocialShareFormat() { |
|
const options = { year: 'numeric', month: 'numeric', day: 'numeric' }; |
|
let string_to_return = ''; |
|
|
|
if (!(window.tutorial_mode)) { |
|
if (window.motive_mode) { |
|
string_to_return = window.social_share.title + "\nMurdle for " + window.today_date.toLocaleDateString("en-US", options) + "\n\n👤🔪🏡❓ 🕰️\n" + window.answers.personRight() + window.answers.weaponRight() + window.answers.locationRight() + window.answers.motiveRight() + " " + window.convertTime() + "\n" + window.answers.numberOfHints(); |
|
} else { |
|
string_to_return = window.social_share.title + "\nMurdle for " + window.today_date.toLocaleDateString("en-US", options) + "\n\n👤🔪🏡 🕰️\n" + window.answers.personRight() + window.answers.weaponRight() + window.answers.locationRight() + " " + window.convertTime() + "\n" + window.answers.numberOfHints(); |
|
} |
|
} else { |
|
string_to_return = window.social_share.title + "\nMini-Murdle for " + window.today_date.toLocaleDateString("en-US", options) + "\n\n👤🔪🏡 🕰️\n" + window.answers.personRight() + window.answers.weaponRight() + window.answers.locationRight() + " " + window.convertTime() + "\n" + window.answers.numberOfHints(); |
|
} |
|
return string_to_return; |
|
} |
|
|
|
function newStreakShareFormat() { |
|
return "⚖️\n" + window.answers.streak(); |
|
} |
|
|
|
// window.newShortSocialShareFormat = newShortSocialShareFormat; |
|
// window.newStreakShareFormat = newStreakShareFormat; |
|
|
|
function reShareNow() { |
|
let text_to_share = newShortSocialShareFormat() + '\n\n' + newStreakShareFormat(); |
|
console.log('reshare:\n', text_to_share); |
|
navigator.clipboard.writeText(text_to_share); |
|
clearAllButtonStyles(); |
|
highlightButton('main-share-button'); |
|
} |
|
|
|
function shortShareNow() { |
|
let text_to_share = newShortSocialShareFormat(); |
|
console.log(text_to_share); |
|
navigator.clipboard.writeText(text_to_share); |
|
clearAllButtonStyles(); |
|
highlightButton('short-share-button'); |
|
} |
|
|
|
function streakShareNow() { |
|
let text_to_share = newStreakShareFormat(); |
|
console.log(text_to_share); |
|
navigator.clipboard.writeText(text_to_share); |
|
clearAllButtonStyles(); |
|
highlightButton('streak-share-button'); |
|
} |
|
|
|
window.reShareNow = reShareNow; |
|
window.shortShareNow = shortShareNow; |
|
window.streakShareNow = streakShareNow; |
|
|
|
function clearButtonStyle(id, value) { |
|
const button = document.getElementById(id); |
|
if (button) { |
|
button.value = value + ' Share'; |
|
button.style.removeProperty('background'); |
|
} |
|
} |
|
|
|
function clearAllButtonStyles() { |
|
clearButtonStyle('main-share-button', 'Full'); |
|
clearButtonStyle('short-share-button', 'Short'); |
|
clearButtonStyle('streak-share-button', 'Streak'); |
|
// clearButtonStyle('fb-share-button'); |
|
// clearButtonStyle('twit-share-button'); |
|
} |
|
|
|
function highlightButton(id) { |
|
const button = document.getElementById(id); |
|
if (button) { |
|
button.style.background = '#A30B37'; |
|
button.value = 'COPIED TO CLIPBOARD'; |
|
} |
|
} |
|
|
|
const waitObserver = new MutationObserver((mutations, waitObs) => { |
|
const share_buttons = document.getElementById('share-buttons'); |
|
if (share_buttons) { |
|
console.log('Share Buttons Exists!'); |
|
waitObs.disconnect(); |
|
|
|
const shareObserver = new MutationObserver((mutations, shareObs) => { |
|
const main_share_button = '<p style="text-align: center"><input id="main-share-button" TYPE="button" NAME="button" value="Full Share" onClick="reShareNow()"></p>' |
|
const short_share_button = '<p style="text-align: center"><input id="short-share-button" TYPE="button" NAME="button" value="Short Share" onClick="shortShareNow()"></p>'; |
|
const streak_share_button = '<p style="text-align: center"><input id="streak-share-button" TYPE="button" NAME="button" value="Streak Share" onClick="streakShareNow()"></p>'; |
|
const fb_share_button = '<p style="text-align: center"><input id="fb-share-button" TYPE="button" NAME="button" value="Share on Facebook" onClick="shareOnFB()"></p>'; |
|
const twit_share_button = '<p style="text-align: center"><input id="twit-share-button" TYPE="button" NAME="button" value="Share on Twitter" onClick="shareOnTwitter()"></p>'; |
|
console.log('Updating Share Buttons'); |
|
shareObs.disconnect(); // So we don't loop for eternity... not that I did that... |
|
share_buttons.innerHTML = main_share_button + short_share_button + streak_share_button + fb_share_button + twit_share_button; |
|
highlightButton('main-share-button'); |
|
// shareObs.observe(share_buttons, {childList: true, subtree: true}); |
|
}); |
|
|
|
shareObserver.observe(share_buttons, {childList: true, subtree: true}); |
|
} |
|
}); |
|
waitObserver.observe(document, {childList: true, subtree: true}); |
|
|
|
})(); |
Version history:
0.0.1 - Initial version
0.0.2 - Add URLs
0.0.3 - Add description to Gist
0.0.4 - Correct URLs