Warning: fopen(/www/sites/update.greasyfork.icu/index/store/forever/37c4e0eeec494d2fd1a0cd26685b6d8f.js): failed to open stream: No space left on device in /www/sites/update.greasyfork.icu/index/scriptControl.php on line 65
// ==UserScript==
// @run-at document-start
// @name General URL Cleaner
// @namespace
// @description Cleans URL's from various popular sites. Also, makes sure the sites are using HTTPS.
// @include /^https?://[a-z]+\.google(\.com?)?\.[a-z]{2,3}/.*$/
// @include /^https?://www\.amazon(\.com?)?\.[a-z]{2,3}/.*$/
// @include /^https?://www\.newegg\.c(om|a)/.*$/
// @include /^https?://[a-z]+\.ebay(\.com?)?\.[a-z]{2,3}/.*$/
// @include /^https?://www\.bing\.com/.*$/
// @include https://www.youtube.com/*
// @include http://stat.dealtime.com/*
// @include http://www.imdb.com/*
// @exclude https://apis.google.com/*
// @exclude https://www.google.com/recaptcha/api2/*
// @version 2.5
// @license GPL version 3 or any later version; http://www.gnu.org/copyleft/gpl.html
// @downloadURL none
// ==/UserScript==
var doc = document; var numLinks = 0;
var docDomain = doc.URL.split('/')[2];
var ebay = /^[a-z]+\.ebay(\.com?)?\.[a-z]{2,3}$/;
var amazon = /^www\.amazon(\.com?)?\.[a-z]{2,3}$/;
var google = /^[a-z]+\.google(\.com?)?\.[a-z]{2,3}$/;
var amazonParams = /&(ie|pf_rd_[a-z]|bbn|rw_html_to_wsrp)=[^]*/;
var utmParams = /([?]utm_[a-z]+=[^]*|&)/g;
var bingParams = /&(go|qs|form|FORM|filt|pq|s[cpk]|qpvt|cvid)=[^&]*/g;
var youtubeParams = /&(feature|src_vid|annotation_id|[gh]l)=[^&]*/g;
var ebayParams = /&(_(o?sacat|odkw|from|trksid)|rt)=[^&]*/g;
var googleParams = /&(aqs|as_qdr|authuser|bav|bi[wh]|bs|bvm|cad|channel|complete|cp|s?client|dpr|es_sm|g(fe|ws)_rd|gpsrc|h[ls]|ie|n?um|btnG|o[eq]|pbx|p[fq]|rct|rlz|sa(fe)?|s?ei|site|source(id)?|spell|tab|tbas|tbo|usg|ved|xhr|gs_(l|r[ni]|mss|id))=[^&]*/g;
// -------- Main --------
if (docDomain=='www.bing.com') {
var newUrl = cleanBingSearch(doc.URL);
if (doc.URL.startsWith('http:')) location.href = newUrl;
else cleanPageUrl(newUrl);
cleanLinks('all');
}
else if (docDomain=='www.youtube.com') {
if (doc.URL.includes('/watch?')||doc.URL.includes('/watch/')) cleanPageUrl(cleanYoutubeVideo(doc.URL));
else if (doc.URL.includes('redirect?')) location.replace(cleanYoutubeRedirect(doc.URL));
cleanLinks('youtube');
}
else if (docDomain=='www.newegg.com' || docDomain=='www.newegg.ca') {
if (doc.URL.includes('/Product/Product.aspx')) cleanPageUrl(cleanNeweggItem(doc.URL));
cleanLinks('newegg');
}
else if (docDomain=='www.imdb.com') {
if (doc.URL.includes('?')) cleanPageUrl(cleanImdb(doc.URL));
cleanLinks('imdb');
}
else if (google.test(docDomain)) {
if (doc.URL.includes('/url?')) location.replace(cleanGoogleRedirect(doc.URL));
else if (doc.URL.includes('/imgres?imgurl=')) location.replace(cleanGoogleImageRedirect(doc.URL));
else if (/\.[a-z]{2,3}\/[a-z]*[?#]/.test(doc.URL)) {
cleanPageUrl(cleanGoogleSearch(doc.URL));
cleanLinks('google',true);
googleInstant();
}
}
else if (ebay.test(docDomain)) {
if (doc.URL.includes('/itm/')) cleanPageUrl(cleanEbayItem(doc.URL));
else if (doc.URL.includes('/sch/')||doc.URL.includes('/dsc/')) cleanPageUrl(cleanEbaySearch(doc.URL));
cleanLinks('ebay');
}
else if (amazon.test(docDomain)) {
if (doc.URL.includes('/dp/')) cleanPageUrl(cleanAmazonItemdp(doc.URL));
else if (doc.URL.includes('/gp/product')) cleanPageUrl(cleanAmazonItemgp(doc.URL));
else if (doc.URL.includes('?')) cleanAmazonParams(doc.URL);
cleanLinks('amazon');
}
else if (doc.URL.startsWith('http://stat.dealtime.com/DealFrame/DealFrame.cmp?')) {
location.replace(cleanDealtime(doc.URL));
}
// -------- Front functions --------
function cleanPageUrl(newUrl) {
if (newUrl != doc.URL) history.replaceState(null,null,newUrl);
}
function cleanLinks(site, remain=false) { new MutationObserver(function(_,self) {
links = doc.getElementsByTagName("a");
if (links.length>numLinks) { numLinks=links.length;
for (var i=numLinks; 0