memchr

u/memchr@lemmy.world
2 posts · 19 comments

Recent posts

Recent comments

on Must resist · c/lemmyworld · 8 pts · 3y
// ==UserScript==
// @name        archive.org link
// @include     *://*.google*/search*
// @include     *://*
// @exclude     *://*.archive.org*
// @exclude     *://archive.org*
// @grant       none
// @version     1.0
// @author      memchr
// @description 6/15/2023, 6:57:32 AM
// ==/UserScript==
function get_archive_href(href) {
  return "https://web.archive.org/web/" + href.replace(/^https?:\/\/www\.reddit\.com/, "https://old.reddit.com")
}

if (window.location.hostname.match(/^(\w*\.)?google.*$/)) { // google
  const results = document.querySelectorAll('div.yuRUbf > a');
  results.forEach(e => {
    let href = e.getAttribute('href');
    href = get_archive_href(href);
    let archive_link = document.createElement('a');
    archive_link.href = href;
    archive_link.textContent = "archive";
    archive_link.style.marginLeft = "10px";
    e.insertAdjacentElement("afterend", archive_link);
  })
} else if (!window.location.hostname.match(/(localhost$|^(127|192|10)\.)/)) {
  const href = get_archive_href(location.href);
  document.addEventListener('keydown', function(event) {
    if (event.ctrlKey && event.altKey && event.key === 'a') {
      window.location.href = href;
    }
  });
}

press shift+ctrl+A or click on archive if you use google.

try this script

// ==UserScript==
// @name        reddit archive link
// @include     *://*.google*/search*
// @include     *://*.reddit.com/r/*
// @grant       none
// @version     1.0
// @author      memchr
// @description 6/15/2023, 6:57:32 AM
// ==/UserScript==
function get_archive_href(href) {
  return href.replace(/https:\/\/www\.reddit/,"https://web.archive.org/web/https://old.reddit");
}

if (window.location.hostname.match(/^(\w*\.)?google.*$/)) { // google
  const results = document.querySelectorAll('div.yuRUbf > a');
  results.forEach(e => {
    let href = e.getAttribute('href');
    if (href.match(/reddit\.com\/r\//)) {
      href = get_archive_href(href);
      let archive_link = document.createElement('a');
      archive_link.href = href;
      archive_link.textContent = "archive";
      archive_link.style.marginLeft = "10px";
      e.insertAdjacentElement("afterend", archive_link);
    }
  })
} else if (window.location.hostname.match(/^(\w*\.)?redd.*$/)) { // reddit shit
  const href = get_archive_href(location.href);

  const button = document.createElement('button');
  button.textContent = 'archive';
  button.style.position = 'fixed';
  button.style.bottom = '20px';
  button.style.left = '20px';
  button.style.backgroundColor = '#655CF2ff';
  button.style.color = 'white';
  button.style.zIndex = '9999';
  button.style.borderRadius = '20px';
  button.style.padding = '5px';
  document.body.appendChild(button);

  button.addEventListener('click', () => {location.replace(href)});
}

It will add a link to archive.org next to the reddit Google search result, or a blue link to archive button in the bottom left corner of a reddit page.

Script manager such as violentmonkey is required.

You are welcome.

However, I suspect it's possibly a system corruption. So check your memory and hard drive to make sure they are OK before using your PC again.

And consider using btrfs, you can take snapshots before updating packages and restore them in case of package corruption.