An alternative implementation of OperaPythonAdblock in the much lighter and faster Lua.
See Opera Adblock page for more adblocking options.
Download and install the tiny Lua executable for your platform. Precompiled binaries are available from here:
http://lua-users.org/wiki/LuaBinaries
You can download a precompiled binary for windows from the wiki: Zipped Lua Win32 Binary (86KB)
You drop that single .exe ideally somewhere where windows can find it (I use the windows/winnt directory). You can also associate .lua files with lua.exe though it is not needed. If you add Lua.exe, the adblock.lua and the adblock.css into Opera's program folder, you do not need to add any absolute paths; it will just work as-is.
Create an empty CSS file where the script will store your blocking rules. For the purposes of illustration, we assume it is named adblock.css, saved in C:\\PATH\\adblock.css, where PATH stands for the directory where you saved the CSS file. Again, if you use Opera's program folder, then you don't need the PATH
Change PATH in the following script to the correct path to the adblock.css file (backslashes in PATH should be double, on *nix use single slashes), then save it as a text file with the .lua extension (e.g. adblock.lua):
if table.getn(arg)<1 then os.exit() end
BLOCK_CSS_FILE="PATH\\adblock.css"
cssFile=io.open(BLOCK_CSS_FILE)
if cssFile then
cssStr=cssFile:read("*a") or ""
cssFile:close()
end
cssFile=io.open(BLOCK_CSS_FILE,"w")
if table.getn(arg)==1 then cssFile:write('img[src="'..arg[1]..'"]')
elseif table.getn(arg)==2 then cssFile:write(arg[2]..'"'..arg[1]..'"]')
elseif table.getn(arg)==3 then cssFile:write(arg[2]..'['..arg[3]..'='..'"'..arg[1]..'"]')
elseif table.getn(arg)==4 then cssFile:write(arg[2]..'['..arg[3]..arg[4]..'"'..arg[1]..'"]')
end
if (cssStr=="\n") or (cssStr=="") then cssFile:write('\n{display:none !important;}')
else cssFile:write(',\n'..cssStr) end
cssFile:close()
The format of the menu command is slightly different to the Python version, we must call Lua and put the arguments in the next slot like so:
Item, "Destroy image" = Copy image address & Execute program, "Lua.exe", "PATH\adblock.lua %c" & Select user CSS file,1 & Deselect user CSS file, 1 & Select user CSS file,1 & Deselect user CSS file, 1
This assumes Lua.exe is somewhere in the path. If not you simply need to specify its path.