Archive.ph Resave

Resave the web page again on archive.ph

目前為 2024-07-26 提交的版本,檢視 最新版本

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

You will need to install an extension such as Tampermonkey to install this script.

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name         Archive.ph Resave
// @namespace    http://tampermonkey.net/
// @version      2024-07-27-00-52
// @description  Resave the web page again on archive.ph
// @author       hangjeff
// @match        https://archive.is/*
// @match        https://archive.ph/*
// @match        https://archive.md/*
// @require      https://code.jquery.com/jquery-3.7.1.slim.min.js
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    // Your code here...
    let savedPage = $('input[name="q"]').val();
    let Bootstrap = $('<link>', {
                	href: 'https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css',
                    rel: 'stylesheet'
                }).appendTo('head');

    if(savedPage.includes('?')){
         if(savedPage.includes('archiveParameter')){
            let archiveParameter = new URLSearchParams(
                new URL(savedPage).search).get('archiveParameter');
             archiveParameter = parseInt(archiveParameter) + 1;

             let params = new URLSearchParams(new URL(savedPage).search);
             params.set('archiveParameter', archiveParameter);
             savedPage = savedPage.substring(0, savedPage.lastIndexOf('?') + 1) + params.toString();
             Form_Create(savedPage);
         }
        else{
            Form_Create(savedPage + '&archiveParameter=1');
        }
    }
    else{
         Form_Create(savedPage + '?archiveParameter=1');
    }
    $('form[action="https://archive.ph/search/"]').css('height', '30');

    $('form[action="https://archive.is/search/"]').css('padding', '15px').css('height', '30px');
    $('#search').css('height', '75px');


    function Form_Create(myUrl){
          let form = $('<form>', {
        			id: 'submiturl',
        			action: 'https://archive.ph/submit/',
        			method: 'GET',
                    class: 'col-2'
    			});

        form.append(
        			$('<input>', {
                		id: 'url',
                		type: 'hidden',
                		name: 'url',
                		value: myUrl
            		})
    			);
        form.append(
        			$('<input>', {
                		type: 'submit',
                		value: 'Save to archive.is again',
                		tabindex: '1',
                        class: 'btn btn-primary'
            		})
    			);

        let btn_Back = $('<button class = "col-2 btn btn-secondary">Go Back to the Page</button>');
        btn_Back.on('click', function(){
           window.open($('input[name="q"]').val());
        })

        let myDiv = $('<div>', {
              class: 'row justify-content-center'
        });
        myDiv.append(form);
        myDiv.append(btn_Back);
        $('#HEADER').prepend(myDiv);
    }
})();