Skip to content

Instantly share code, notes, and snippets.

@TONYHOKAN
Last active April 20, 2019 11:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save TONYHOKAN/68798477484cdf6b411b34b165ebb8e7 to your computer and use it in GitHub Desktop.
Save TONYHOKAN/68798477484cdf6b411b34b165ebb8e7 to your computer and use it in GitHub Desktop.
compare hktvmall product price to other sites
// ==UserScript==
// @name compare hktvmall product price to other sites
// @namespace http://tampermonkey.net/
// @version 0.1
// @description try to take over the world!
// @author TONYHOKAN
// @match https://www.hktvmall.com/*/p/*
// @grant none
// ==/UserScript==
(function() {
'use strict';
var parknshopUrl = 'http://www.parknshop.com/zh-hk/search?text=';
var zstoreUrl = 'https://www.ztore.com/tc/search/'
var priceComUrl = 'https://www.price.com.hk/search.php?g=A&q='
var googleUrl = 'https://www.google.com.hk/search?q='
var productTitle = encodeURI($('.last').html())
$('.bottomButtons').append(genCheckButton(parknshopUrl+productTitle, 'parknshop'))
$('.bottomButtons').append(genCheckButton(zstoreUrl+productTitle, 'zstore'))
$('.bottomButtons').append(genCheckButton(priceComUrl+productTitle, 'price.com'))
$('.bottomButtons').append(genCheckButton(googleUrl+productTitle + ' -site:https://www.hktvmall.com/', 'google'))
function genOnClick(url)
{
// var searchUrl = 'onclick="window.location.href=\'' + targetUrl + productTitle + '\'"'
return 'onclick="window.open(\''+url+'\', \'_blank\')"'
}
function genCheckButton(url, buttonString)
{
return '<div class="buttonWrapper"><button class="sepaButton large" ' + genOnClick(url) + '><div class="spriteWrapper"></div><span>' + buttonString + '</span></button></div>'
}
})();
f
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment