Skip to content

Commit

Permalink
Implemented to archive website.
Browse files Browse the repository at this point in the history
  • Loading branch information
adamthewilliam committed Dec 11, 2023
1 parent 5bf5c1d commit 1a0927d
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 18 deletions.
6 changes: 3 additions & 3 deletions background.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
chrome.storage.session.setAccessLevel({ accessLevel: 'TRUSTED_AND_UNTRUSTED_CONTEXTS' });

const initialUrlDestination = "https://archive.org/";
const initialUrlDestination = "https://archive.ph/";
const finalUrlDestination = "https://web.archive.org/web";

chrome.runtime.onInstalled.addListener(async () => {
Expand Down Expand Up @@ -43,14 +43,14 @@ chrome.tabs.onCreated.addListener(function onCreateListener(tab) {
}
else {
if(currentTab.index !== onUpdatedTab.index) {
if(onUpdatedTab.url.startsWith(finalUrlDestination)) {
//if(onUpdatedTab.url.startsWith(finalUrlDestination)) {

console.log("We are in a different tab and will make a push notification");

handleNotification(onUpdatedTab.index);

chrome.tabs.onUpdated.removeListener(listener);
}
// }
}
else {
console.log("We are currently in the same tab. Add value to textbox and submit form");
Expand Down
40 changes: 25 additions & 15 deletions script.js
Original file line number Diff line number Diff line change
@@ -1,25 +1,35 @@

chrome.storage.session.get(['urlToBeArchived'], function(result) {
console.log('Url to be archived is: ' + result.urlToBeArchived);

var shadowRoot = document.querySelector('app-root').shadowRoot;
console.log(shadowRoot);

var routerSlotElement = shadowRoot.querySelector('router-slot');
console.log(routerSlotElement);
const currentUrl = window.location.href;

var homeShadow = routerSlotElement.querySelector('home-page').shadowRoot;
console.log(homeShadow);
if(currentUrl === "https://web.archive.org/") {
var shadowRoot = document.querySelector('app-root').shadowRoot;
console.log(shadowRoot);

var containerShadow = homeShadow.querySelector('ia-wayback-search').shadowRoot;
console.log('Container Shadow' + containerShadow);
var routerSlotElement = shadowRoot.querySelector('router-slot');
console.log(routerSlotElement);

var textBox = containerShadow.querySelector('#url');
textBox.value = result.urlToBeArchived;
var homeShadow = routerSlotElement.querySelector('home-page').shadowRoot;
console.log(homeShadow);

var form = containerShadow.querySelector('form');
console.log(form);
form.requestSubmit();
});
var containerShadow = homeShadow.querySelector('ia-wayback-search').shadowRoot;
console.log('Container Shadow' + containerShadow);

var textBox = containerShadow.querySelector('#url');
textBox.value = result.urlToBeArchived;

var form = containerShadow.querySelector('form');
console.log(form);
form.requestSubmit();
}

if(currentUrl === "https://archive.ph/") {
var form = document.querySelector('#submiturl');
var textBox = form.querySelector('#url');

textBox.value = result.urlToBeArchived;
form.requestSubmit();
}
});

0 comments on commit 1a0927d

Please sign in to comment.