Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG]: Artifact with archive.(today|ph|is|li|vn|fo|md) as well as same method from URLs when opening link in an archive #77

Open
ccuser44 opened this issue Nov 1, 2023 · 0 comments

Comments

@ccuser44
Copy link

ccuser44 commented Nov 1, 2023

Is your feature request related to a problem? Please describe.

  • When you go to the archive of a link (or the page) and when you are already on an archived version of some page on archive.(today|ph|is|li|vn|fo|md) the archive.(today|ph|is|li|vn|fo|md) part of the link is not stripped which causes the new link to be invalid.
  • This also happens if you use the same archiving service again: google -> google, archive.org -> archive.org
  • However archive links should not be always stripped because it can be perfectly valid to use them in most cases. Only do if the artifact is either archive.(today|ph|is|li|vn|fo|md) or the same archiving service.

Describe the solution you'd like

  • When you click the open in an archive button the link should be stripped of archive.(today|ph|is|li|vn|fo|md) or if the archiving service is same then the archive artifact as well.

Describe alternatives you've considered

  • Going to the raw URL and then going to the archived one. This one is tedious when you have to do it every time and sometimes you get redirected to a diffferent URL which causes more issues.
  • Stripping the URL manually. This is very cumbersome and sometimes link encoding makes it harder.
  • Creating a user script to do this. This is exactly what I've done however all other users would have to do the same and there really isn't any reason the plugin itself shouldn't be able to do this.

Additional context

I've made two userscripts for myself which solve the issue. Both on archive.(today|ph|is|li|vn|fo|md) and archive.org

// ==UserScript==
// @name        archive.today fix  web archives add-on artifact
// @namespace   Link fixer
// @match       https://archive.*/https://archive.*/*/*
// @match       https://archive.*/newest/https://archive.*/*/*
// @run-at      document-start
// @grant       none
// @icon        https://archive.is/apple-touch-icon.png
// @version     1.0
// @author      ccuser44
// @license     CC0
// @description If an archive.(today|ph|is|li|vn|fo|md) link has a URL artifact because of the web archives add-on then the artifact gets removed
// ==/UserScript==

/*
To the extent possible under law, the author(s) have dedicated all copyright and related and neighboring rights to this software to the public domain worldwide.
This software is distributed without any warranty.
You should have received a copy of the CC0 Public Domain Dedication along with this software. If not, see <http://creativecommons.org/publicdomain/zero/1.0/>.
*/

var matches = document.location.href.match(/^https?:\/\/archive\.(is|ph|li|today)(\/newest)?\/https?:\/\/archive\.(today|ph|is|li|vn|fo|md)(\/o\/\w+\/|\/\d+\/)?(.+)/);

if (matches[5]) {
	window.stop();
	window.location.replace("https://archive." + matches[1] + (matches[2] ? matches[2] : "") + "/" + matches[5]);
};

and

// ==UserScript==
// @name        archive.org fix archive.today web archives add-on artifact
// @namespace   Link fixer
// @match       https://web.archive.org/web*https://archive.*/*
// @run-at      document-start
// @grant       none
// @icon        https://archive.org/offshoot_assets/assets/ia-logo-2c2c2c.03bd7e88c8814d63d0fcb35fc01f37c3.svg
// @version     1.0
// @author      ccuser44
// @license     CC0
// @description If a web.archive.org link has an archive.(today|ph|is|li|vn|fo|md) artifact because of the web archives add-on then the artifact gets removed
// ==/UserScript==

/*
To the extent possible under law, the author(s) have dedicated all copyright and related and neighboring rights to this software to the public domain worldwide.
This software is distributed without any warranty.
You should have received a copy of the CC0 Public Domain Dedication along with this software. If not, see <http://creativecommons.org/publicdomain/zero/1.0/>.
*/

var matches = document.location.href.match(/^https:\/\/web\.archive\.org\/web\/([\*\d\-]+\/)?https:\/\/archive\.(today|ph|is|li|vn|fo|md)(\/newest)?(\/o\/\w+|\/\d+)?\/(.+)/);

if (matches[5]) {
	window.stop();
	window.location.replace("https://web.archive.org/web/" + (matches[1] ? matches[1] : "") + matches[5]);
};

Ideally the solution shouldn't be done when visiting the URL but the link should be converted before the add-on requests the browser to open a new tab.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant