By Yehuda B.
—
Last update
Sep 27, 2008
—
Installed
134 times.
// Steimatzky fixer user script
// version 0.1
// 2008-09-27
// Copyright (c) 2008, Yehuda B.
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// http://www.gnu.org/licenses/gpl.html
//
// ==UserScript==
// ==UserScript==
// @name Steimatzky fixer
// @namespace http://yehudab.com
// @description Fix "add to basket" button in Steimatzky (Israeli books publisher) web site. Version 0.1
// @include http://www.steimatzky.co.il/*
// ==/UserScript==
function fixAddtoBasketButton()
{
var numFixed = 0;
var allButtons = document.getElementsByClassName("AddtoBasketButton");
if (allButtons != null)
{
var i, l = allButtons.length, onclickTxt, matches, otherElement;
for (i = 0; i < l; i++)
{
onclickTxt = allButtons[i].getAttribute("onclick");
if (onclickTxt != null)
{
matches = onclickTxt.match(/javascript\:document\.getElementById\('([^']+)'\)\.click/);
if (matches != null)
{
otherElement = document.getElementById(matches[1]);
if (otherElement != null)
{
onclickTxt = otherElement.href;
allButtons[i].setAttribute("onclick", onclickTxt);
numFixed++;
}
}
}
}
}
if (numFixed > 0)
{
GM_log("Successfully fixed " + numFixed + " button(s)");
}
}
fixAddtoBasketButton();