Skip to content

Instantly share code, notes, and snippets.

@larytet
Last active August 29, 2015 14:23
Show Gist options
  • Save larytet/21fb14d5a71f2870d56d to your computer and use it in GitHub Desktop.
Save larytet/21fb14d5a71f2870d56d to your computer and use it in GitHub Desktop.
GreaseMonkey script for Yad2: Update the ads. If you have posted lot of ads this script is for you. Also opens all posted ads for review and editing.
// ==UserScript==
// @name Yad2 Ad update
// @namespace yad2
// @description Simulates click on "kaftor3"
// @include http://my.yad2.co.il/MyYad2/MyOrder/Yad2.php
// ==/UserScript==
// Use chromium-browser --enable-easy-off-store-extension-install to install offline
// in Chrome
/*
Dynamically adds to the page http://my.yad2.co.il/MyYad2/MyOrder/Yad2.php frames containing the advertised items. Update the ads
There is a ~5s delay between the frames. If you have lot of ads posted this can take some time. The frames are added at the bottom of the page. The original functionality page is not affected - you can still edit the ads, post new ad and so on.
Manually install in chromium:
1. Download the script
2. Make sure that the extension is *.user.js
3. Restart the browser chromium-browser --enable-easy-off-store-extension-install
4. Drag and drop the file to any tab in the browser
OR
Drag and drop *.user.js file to the extensions page.
Do you feel that the script helps you out? Let me know or leave a review. Feel free to donate PayPal larytet@yahoo.com Any amount is appreciated.
Patch for Cars
--- /tmp/2.js 2012-07-14 15:25:58.000000000 +0300
+++ /tmp/1_cars.user.js 2012-07-14 15:33:04.000000000 +0300
@@ -1,15 +1,15 @@
// ==UserScript==
-// @name Yad2 Ad update
-// @namespace yad2
+// @name Yad2 Ad update cars
+// @namespace yad2 Cars
// @description Simulates click on "kaftor3"
-// @include http://my.yad2.co.il/MyYad2/MyOrder/Yad2.php
+// @include http://my.yad2.co.il/MyYad2/MyOrder/Car.php
// ==/UserScript==
function updateAd(idNum)
{
- // Something like this "http://my.yad2.co.il/MyYad2/MyOrder/Yad2Details.php?SalesID=5406501&Up=u"
- locationHref="http://my.yad2.co.il/MyYad2/MyOrder/Yad2Details.php?SalesID="+idNum+"&Up=u";
+ // Something like this "http://my.yad2.co.il/MyYad2/MyOrder/CarDetails.php?CarID=5406501&Up=u"
+ locationHref="http://my.yad2.co.il/MyYad2/MyOrder/CarDetails.php?CarID="+idNum+"&Up=u";
javascript:iframe=document.createElement("iframe");
iframe.setAttribute("id", "iframeu"+idNum);
iframe.setAttribute("src", locationHref);
Accessories
--- ./1.0_2/script.js 2013-09-08 08:25:30.567065143 +0200
+++ ./1.0_1/script.js 2013-09-08 08:19:06.243048781 +0200
@@ -1,15 +1,15 @@
// ==UserScript==
-// @name Yad2 Car Accessory Ad update
+// @name Yad2 Ad update
// @namespace yad2
// @description Simulates click on "kaftor3"
-// @include http://my.yad2.co.il/MyYad2/MyOrder/Accessory.php
+// @include http://my.yad2.co.il/MyYad2/MyOrder/Yad2.php
// ==/UserScript==
function updateAd(idNum)
{
- // Something like this "http://my.yad2.co.il/MyYad2/MyOrder/AccessoryDetails.php?CarID=5406501&Up=u"
- locationHref="http://my.yad2.co.il/MyYad2/MyOrder/AccessoryDetails.php?CarID="+idNum+"&Up=u";
+ // Something like this "http://my.yad2.co.il/MyYad2/MyOrder/Yad2Details.php?SalesID&Up=u"
+ locationHref="http://my.yad2.co.il/MyYad2/MyOrder/Yad2Details.php?SalesID="+idNum+"&Up=u";
javascript:iframe=document.createElement("iframe");
iframe.setAttribute("id", "iframeu"+idNum);
iframe.setAttribute("src", locationHref);
*/
function updateAd(idNum)
{
// Something like this "http://my.yad2.co.il/MyYad2/MyOrder/Yad2Details.php?SalesID=5406501&Up=u"
locationHref="http://my.yad2.co.il/MyYad2/MyOrder/Yad2Details.php?SalesID="+idNum+"&Up=u";
javascript:iframe=document.createElement("iframe");
iframe.setAttribute("id", "iframeu"+idNum);
iframe.setAttribute("src", locationHref);
iframe.setAttribute("width", "100%");
iframe.setAttribute("height", "850");
iframe.setAttribute("src", locationHref);
document.body.appendChild(iframe);
}
function removeAd(idNum)
{
iframe = document.getElementById("iframeu"+idNum)
if (iframe)
{
document.body.removeChild(iframe);
}
}
function updateAds(command)
{
var idRegExp = new RegExp("Txt_([0-9]+)");
var tds = document.getElementsByTagName("TD");
idNumPrev = 0;
idFirst = 1;
idHandled = 0;
for (var i = 0;i < tds.length; i++)
{
td = tds[i];
matchId = idRegExp.exec(td.id);
if (!matchId)
{
continue;
}
idNum = matchId[1];
if (!idNum)
{
continue;
}
if (idNum == idNumPrev)
{
continue;
}
if (command == "rm")
{
window.setTimeout("removeAd("+idNum+")", 100);
}
else if (command == "mk")
{
loadTime = idHandled*5*1000;
window.setTimeout("updateAd("+idNum+")", loadTime);
if (idFirst == 1)
{
window.setTimeout("updateAd("+idNum+")", loadTime+1000);
idFirst = 0;
}
}
else
{
window.setTimeout("removeAd("+idNum+")", 100);
loadTime = idHandled*5*1000;
window.setTimeout("updateAd("+idNum+")", loadTime);
}
idHandled = idHandled + 1;
idNumPrev = idNum;
}
}
unsafeWindow.removeAd = removeAd;
unsafeWindow.updateAd = updateAd;
unsafeWindow.updateAds = updateAds;
unsafeWindow.updateAds("rm");
unsafeWindow.updateAds("mk");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment