+  HandyCache форум
|-+  Главная категория» English forum» Extension script for Content delay
Имя пользователя:
Пароль:
Страниц: 1 [2]  Все   Вниз
  Отправить эту тему    Печать  
Автор Тема: Extension script for Content delay  (Прочитано 17965 раз)
0 Пользователей и 1 Гость смотрят эту тему.
truefriend-cz
Постоялец
***

Репутация: +3/-1
Offline Offline

Сообщений: 118


« Ответ #20 : 25 декабря 2012, 16:34:47 »

I modified the script by posts but it does not proccess.

Код:
--[[ <HCExtension>
@name          Test-image
@event         BeforeRequestHeaderSend/Request
@event         AnswerHeaderReceived/Answer
</HCExtension> ]]


function GetContentType(s)
  _,_,x = string.find(s, '[cC]ontent%-[tT]ype: *([^;\r\n]+)')
  if x~=nil then x = string.lower(x)
  end
  return x
end

function Request()
  if re.find(hc.url, [[^[^?]+\.(ani|bmp|cal|fax|gif|img|jbg|jpe|jpeg|jpg|mac|pbm|pcd|pcx|pct|pgm|png|ppm|psd|ras|tga|tiff|wmf)(\?|$)]], 0) and if hc.cache_file_name== '' then
    hc.sleep(2000)
    hc.monitor_string = hc.monitor_string..'Ext-Image '
  end
end

function Answer()
  if hc.method == 'GET' then
    type = GetContentType(hc.answer_header)
    if type~=nil then img = string.find(type,'image',1,true)
      else img = nil
end
    if img~=nil and hc.cache_file_name== '' then
      hc.sleep(2000)
      hc.monitor_string = hc.monitor_string..'Ext-Image '
    end
  end
end
Сообщить модератору   Записан
mirny
Пользователь
**

Репутация: +11/-1
Offline Offline

Сообщений: 84


« Ответ #21 : 25 декабря 2012, 16:41:05 »

That's because you fucked up syntax. Replace and if with just and.
Сообщить модератору   Записан
truefriend-cz
Постоялец
***

Репутация: +3/-1
Offline Offline

Сообщений: 118


« Ответ #22 : 25 декабря 2012, 16:45:00 »

Even when it does not work fix. Strange is that it fails Request section.

Код:
--[[ <HCExtension>
@name          Test-image
@event         BeforeRequestHeaderSend/Request
@event         AnswerHeaderReceived/Answer
</HCExtension> ]]


function GetContentType(s)
  _,_,x = string.find(s, '[cC]ontent%-[tT]ype: *([^;\r\n]+)')
  if x~=nil then x = string.lower(x)
  end
  return x
end

function Request()
  if re.find(hc.url, [[^[^?]+\.(ani|bmp|cal|fax|gif|img|jbg|jpe|jpeg|jpg|mac|pbm|pcd|pcx|pct|pgm|png|ppm|psd|ras|tga|tiff|wmf)(\?|$)]], 0) and if hc.cache_file_name== '' then
    hc.sleep(2000)
    hc.monitor_string = hc.monitor_string..'Ext-Image '
  end
end

function Answer()
  if hc.method == 'GET' then
    type = GetContentType(hc.answer_header)
    if type~=nil then img = string.find(type,'image',1,true)
      else img = nil
end
    if img~=nil and if hc.cache_file_name== '' then
      hc.sleep(2000)
      hc.monitor_string = hc.monitor_string..'Ext-Image '
    end
  end
end
« Последнее редактирование: 25 декабря 2012, 17:02:47 от truefriendcz » Сообщить модератору   Записан
Михаил
Gold beta tester
*****

Репутация: +337/-14
Offline Offline

Сообщений: 5513



« Ответ #23 : 25 декабря 2012, 21:13:24 »

May be:
Код:
--[[ <HCExtension>
@name          Test-image
@event         BeforeRequestHeaderSend
</HCExtension> ]]

function BeforeRequestHeaderSend()
  if re.find(hc.url, [[\A[^?]+\.(ani|bmp|cal|fax|gif|img|jbg|jpe|jpeg|jpg|mac|pbm|pcd|pcx|pct|pgm|png|ppm|psd|ras|tga|tiff|wmf)(\?|\z)]]) then
    hc.sleep(2000)
    hc.monitor_string = hc.monitor_string..'Ext-Image '
    hc.action = 'dont_update'
  else
    hc.call_me_for('AnswerHeaderReceived')
  end
end

function AnswerHeaderReceived()
    if not re.find(hc.answer_header, [[\A\S++\s*+200.*?^content-type:\s*+image]]) then return end
    hc.sleep(2000)
    hc.monitor_string = hc.monitor_string..'Ext-Image '
    hc.action = 'dont_update'
end
Сообщить модератору   Записан
truefriend-cz
Постоялец
***

Репутация: +3/-1
Offline Offline

Сообщений: 118


« Ответ #24 : 25 декабря 2012, 23:37:05 »

Михаил This version of the script does not work.
Сообщить модератору   Записан
Anymore
Beta tester
*****

Репутация: +17/-0
Offline Offline

Сообщений: 339


« Ответ #25 : 26 декабря 2012, 01:51:30 »

all the easier
Код:

--[[ <HCExtension>
@name          Test-image (E.Delay)
@description   http://handycache.ru/forum/index.php?topic=5913.0
@event         BeforeRequestHeaderSend
</HCExtension> ]]

function BeforeRequestHeaderSend()
  hc.call_me_for('AnswerHeaderReceived')
end

function AnswerHeaderReceived()
  if re.find(hc.answer_header, [[\A\S++\s*+200.*?^content-type:\s*+image]]) then
    hc.sleep(4000)
    hc.monitor_string = hc.monitor_string..'E.Delay '
  end
end

Сообщить модератору   Записан
Влад22
Пользователь
**

Репутация: +2/-9
Offline Offline

Сообщений: 97


« Ответ #26 : 26 декабря 2012, 18:46:44 »

Извиняюсь за плохой английский )
Случайно поставил себе это расширение, и опера 12,12 начала летать!
У меня нет логичного объяснения этого эффекта, но факт остаётся фактом  lol
Сообщить модератору   Записан
Anymore
Beta tester
*****

Репутация: +17/-0
Offline Offline

Сообщений: 339


« Ответ #27 : 26 декабря 2012, 19:09:27 »

Влад22, google corporation and other dont support opera browser.
Сообщить модератору   Записан
truefriend-cz
Постоялец
***

Репутация: +3/-1
Offline Offline

Сообщений: 118


« Ответ #28 : 19 сентября 2013, 14:14:24 »

all the easier
Код:

--[[ <HCExtension>
@name          Test-image (E.Delay)
@description   http://handycache.ru/forum/index.php?topic=5913.0
@event         BeforeRequestHeaderSend
</HCExtension> ]]

function BeforeRequestHeaderSend()
  hc.call_me_for('AnswerHeaderReceived')
end

function AnswerHeaderReceived()
  if re.find(hc.answer_header, [[\A\S++\s*+200.*?^content-type:\s*+image]]) then
    hc.sleep(4000)
    hc.monitor_string = hc.monitor_string..'E.Delay '
  end
end


How can edit this script for better use? Images is processed serial (each file loading 4000 ms - 10 images is 40000 ms) it would be possible to modify the script to work with files in parallel (all files in one time loading 4000 ms)? And if file is in cache load without this script (excluse)?
Сообщить модератору   Записан
Страниц: 1 [2]  Все   Вверх
  Отправить эту тему    Печать  

 
Перейти в: