[TS] Linx Amender

Generic tracking/redirection/open-in-new-tab removal; Amend page title; URL redirector; and more power functionality. Has rules for Pixiv, deviantArt, twitter, youtube, blogger, Batota etc.

< Feedback on [TS] Linx Amender

Question/comment

§
Posted: 2015/06/26

help with converting embed code

if you're bored :) could you take a peek at this...

object is to convert embed/object code to code which FF can render without Flash installed - in this particular case i don't know that it's even possible, but i'd like to try it

reference page: http://www.theyrule.net/

regex code page: https://www.regex101.com/r/uN6mR0/1

TS:LA rule:

`{"id":"L1415935007717","name":"[generic] change visited link color","URLs":"@https://addons.mozilla.org/\n@http://imdb.com/\n@https://kickass.to/\n@https://msdn.microsoft.com/\n@https://scholar.google.com/\n@https://startpage.com/\n@https://www.google.com/\n@https://wordpress.org/\n@http://workampingjobs.com/","description":"change color of visited links to hot pink\nnote that the '¬' char in the help text is not the same as from the windows character map","nthNode":"0","script":"a:visited {color: #FF0080 !important;}","type":6,"selectors":"a","regexes":[],"enabled":true,"timestamp":1434286322456}`

the rule does not seem to work at all - the original html is not being replaced - the 'search' expression is what i think i need help with, the replace i can handle

TimidScriptAuthor
§
Posted: 2015/06/27
Edited: 2015/06/27

Not bored just recovering from a long illness.

Anyway, please copy the rule in a pre html tags because I am unable to do anything with the rule above. It's unable to import it as it is broken due to the fact as it has been treated as html when you posted it.

Post below rather than edit so I can get notified. I think you posted the wrong rule. ^_^

§
Posted: 2015/06/27

i wasn't accusing you of being bored - just saying that i could use some help IF you happen to be bored :)

i forgot how to post code here and couldn't find help in the 'help' section, so maybe this will work

however, the code might be less important than the link i gave above for the RegEx site

{"id":"L1435335661255","name":"[generic] embed convert","URLs":"*","nthNode":"0","type":1,"selectors":"embed","regexes":[{"name":"=outerHTML","search":"(?:<object[\\s\\S]+?)?<embed.*?src=\"(\\S+?)\"[\\s\\S]*?(width=\".*?\").*?(height=\".*?\")[\\s\\S]*?>[\\s\\S]*?(?:<\\/object>|<\\/embed>)","replace":"<h1>HI</h1>"}],"enabled":false,"timestamp":1435339760959}

TimidScriptAuthor
§
Posted: 2015/06/27

No accusation :)

The multiline flag is not supported. Good thing you posted it as I will now try and include it in version 4.

As to the rest, unless the order of the element attribute is the same it will not work. Also it won't work if elements are missing.

Below is the regular expression that extracts the src, width and height. It expects all to be present and the height to be last. If anything are missing, it won't work.

.+(src=["'][^"']+["']).+((width|height)=["'][^"']+["']).+((width|height)=["'][^"']+["']).+

It will work on the iframe replace in the regex101 example you gave above. If there are any missing attributes, it will fail.

§
Posted: 2015/06/27

will pay more attention to the attrib order - i knew that, but overlooked it apparently

as for the expression flags, maybe it would be best to let the user enter them as needed??? shouldn't be a problem since they already have to know RegExp

for example, to add 'i', 'm' and 'g', maybe they would have to prefix the expression with '(?img)'

of course you run into a problem with backward compatibility with existing rules, so maybe the 'global' and 'case-insensitive' flags should remain hard-coded - i'm guessing the multi-line flag could significantly slow the script run time, so maybe that one should have to be used manually '(?m)'

§
Posted: 2015/06/27

hmmm - still having trouble with this...

the global and multi-line flags are not needed and i did have the attrib order correct, so if you see here (i updated the replace exp to make it simple)... https://www.regex101.com/r/uN6mR0/2 it works in the example, but it doesn't work with TS:LA and i don't understand why - the source code i used for the example is a direct copy from the source code of the webpage (http://www.theyrule.net/)

perhaps something with char encoding? or something else?

TimidScriptAuthor
§
Posted: 2015/06/27

as for the expression flags, maybe it would be best to let the user enter them as needed??? shouldn't be a problem since they already have to know RegExp

The new interface is designed to be more helpful. It's been delayed to health issues but I plan to start working on it again soonish. Preview attached below if you are interested. I just added the the dummy flag buttons just to show you how it most likely be implemented.

of course you run into a problem with backward compatibility with existing rules, so maybe the 'global' and 'case-insensitive' flags should remain hard-code

All old rules will be converted to new format. Once upgraded to version 4, you cannot go back to version 3. Almost all old rules should convert without issues (I hope).

Only thing that will break javascript rules that use variables. I do not know why I included external variables in the first place. I must've been high. I use it, but its moronic.

the global and multi-line flags are not needed and i did have the attrib order correct, so if you see here (i updated the replace exp to make it simple)..

Your knowledge of regex seems to be a lot better than mine. I just learned a new operator from your expression :/

Anyhow, the problem is the order of the attributes differ on the site. Height comes first on the site. Also in the example above, for the node selector you gave embed instead of object. Not sure if you wanted that or not.

Below expression should work no matter the order of width/height. You could also include src with a little alteration.


###Preview of the editor
<img src="https://greasyfork.org/en/forum/uploads/FileUpload/10/d8fe5d8eade359b9f5f93cad14fe1d.png" />
§
Posted: 2015/06/28

thanks Timid - i like the new UI

regarding the object/embed targeting, i was trying to eliminate the object code completely since it doesn't seem to be needed, then convert the embed code to iframe as this seems the only way FF can use it without Flash

no worries - i'll get it eventually

thanks, and i hope your health issue is on a path to recovery

TimidScriptAuthor
§
Posted: 2015/06/28

Thank you :)

Post reply

Sign in to post a reply.