我试图为OCmod 2.3.0.2创建一个OpenCart扩展,以防止(尽可能多地)从客户网站复制/下载内容。我通过手动将代码添加到我在扩展名中调用的文件中来测试代码,它可以正常工作。
下面是我创建的OCmod扩展:
<modification>
<name>Copy protection</name>
<version>v1.0</version>
<author>SporeDev</author>
<code>copy-protection</code>
<file path="catalog/view/theme/*/template/common/header.tpl">
<!-- Insert the JS call required in the header -->
<operation>
<search><![CDATA[<body]]></search>
<add position="replace"><![CDATA[<body onkeypress="return disableCtrlKeyCombination(event);" onkeydown="return disableCtrlKeyCombination(event);"]]></add>
</operation>
<!-- Insert the JS call required in the header -->
<operation>
<search><![CDATA[</head>]]></search>
<add position="before"><![CDATA[<script>function clickIE(){if(document.all)return!1}function clickNS(e){if((document.layers||document.getElementById&&!document.all)&&(2==e.which||3==e.which))return!1}function disableCtrlKeyCombination(e){var n,o,t=new Array("a","n","c","x","v","j","w");if(window.event?(n=window.event.keyCode,o=!!window.event.ctrlKey):(n=e.which,o=!!e.ctrlKey),o)for(i=0;i<t.length;i++)if(t[i].toLowerCase()==String.fromCharCode(n).toLowerCase())return alert("Key combination CTRL + "+String.fromCharCode(n)+" has been disabled."),!1;return!0}document.onkeypress=function(e){if(123==(e=e||window.event).keyCode)return!1},document.onmousedown=function(e){if(123==(e=e||window.event).keyCode)return!1},document.onkeydown=function(e){if(123==(e=e||window.event).keyCode)return!1};var message="Sorry, right-click has been disabled";document.layers?(document.captureEvents(Event.MOUSEDOWN),document.onmousedown=clickNS):(document.onmouseup=clickNS,document.oncontextmenu=clickIE),document.oncontextmenu=new Function("return false");</script>]]></add>
</operation>
</file>
<!-- Modify the CSS to prevent dragging the photo in a new tab -->
<file path="catalog/view/theme/*/stylesheet/stylesheet.css">
<operation>
<search><![CDATA[]]></search>
<add position="bottom"><![CDATA[body{-webkit-touch-callout:none;-webkit-user-select:none;-khtml-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none} img{-moz-user-select:none;-webkit-user-select:none;-ms-user-select:none;user-select:none;-webkit-user-drag:none;user-drag:none;-webkit-touch-callout:none}]]></add>
</operation>
</file>
<!-- Modify the img tag to prevent dragging the photo in a new tab -->
<file path="catalog/view/theme/*/template/product/product.tpl">
<operation>
<search><![CDATA[<img]]></search>
<add position="replace"><![CDATA[<img draggable="false" ondragstart="return false;"]]></add>
</operation>
</file>
<!-- Modify the lightbox img tag to prevent dragging the photo in a new tab -->
<file path="catalog/view/javascript/jquery/magnific/jquery.magnific-popup.min.js">
<operation>
<search><![CDATA[<img]]></search>
<add position="replace"><![CDATA[<img draggable="false" ondragstart="return false;"]]></add>
</operation>
</file>
</modification>该扩展似乎正常工作(防止右键单击和CTRL命令),直到它进入第一个“前”操作,该操作应该阻止用户在没有链接的情况下拖动照片,在新选项卡中打开它们。
我需要在stylesheet.css底部插入CSS。OCmod支持“底部”还是只有vQmod才能实现?
发布于 2017-07-19 19:22:58
OCMOD缺少属性:顶部、底部、iafter、iafter
但你可以使用REGEX。例如,如果您需要文件底部,请使用:
<search regex="true" limit="1"><![CDATA[($)]]></search>https://stackoverflow.com/questions/44295056
复制相似问题