I'm trying to make a script that I use in Chrome work for safari. It uses a lookbehind regex to skip a page, but Safari doesn't support that. It recognises the amazon ASIN and puts together a link.
This is the original code I found somewhere on the web;
// ==UserScript==
// @name PartAlert
// @namespace http://tampermonkey.net/
// @version 1.1
// @description try to take over the world!
// @author You
// @match https://partalert.net/*
// @icon https://www.google.com/s2/favicons?domain=partalert.net
// @grant none
// ==/UserScript==
(function() {
'use strict';
var url = window.location.href;
var regexAsin= RegExp("(?<=asin=)(.+)(?=&price)");
var regexCountry= RegExp("(?<=tld=.)(.+)");
var mAsin = url.match(regexAsin);
var mCountry = url.match(regexCountry);
var finalSite = "https://www.amazon."+ mCountry[0]+ "/dp/" + mAsin[0] + "?tag=test";
// window.location.href = finalSite;
window.location.href = finalSite + "&psc=1&aod=1&condition=all"
})();
I tried replacing the lookbehind regex as suggested in this question;
var regexAsin= RegExp("(?:asin=)(.+)(?=&price)");
var regexCountry= RegExp("(?:tld=.)(.+)");
but when I replace those the URL gets messed up and will have tld=
before the extension.
To test this script you could use a url like this one.