簡體   English   中英

OpenCart OCmod使用“底部”

[英]OpenCart OCmod using “bottom”

我正在嘗試為OpenCart 2.3.0.2創建OCmod擴展,以阻止(盡可能)從客戶端網站復制/下載內容的功能。 我通過手動將代碼添加到在擴展名中調用的文件中來測試代碼,它可以正常工作。

這是我創建的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命令),直到進入第一個“之前”操作為止為止,該操作應防止用戶拖動照片而沒有鏈接以在新選項卡中打開它們。

我需要將該CSS插入stylesheet.css的底部。 OCmod是否支持“底部”或僅通過vQmod可以實現?

OCMOD缺少的屬性:top,bottom,ibefore,iafter

但是您可以使用REGEX。 例如,如果您需要文件底部,請使用:

<search regex="true" limit="1"><![CDATA[($)]]></search>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM